Skip to content

Instantly share code, notes, and snippets.

@Bash-Clevin
Created November 16, 2023 16:22
Show Gist options
  • Save Bash-Clevin/a82645d5bcf82e70ccd7b121ef4b49a6 to your computer and use it in GitHub Desktop.
Save Bash-Clevin/a82645d5bcf82e70ccd7b121ef4b49a6 to your computer and use it in GitHub Desktop.
Build Ansible image with docker compose + Dockerfile

This setup allows you to build an ansible image based on ubuntu.

It will setup automatically skipping the interactive mode which requires setup of timezone during ansible installation

Feel free to substitute the ENV TZ with your current timezone

Ansible docs

version: '3'
services:
ansible-control:
build:
context: .
dockerfile: Dockerfile
container_name: ansible-control
volumes:
- ./:/ansible
command: tail -f /dev/null
FROM ubuntu:23.10
WORKDIR /ansible
ENV TZ=Africa/Nairobi
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone \
&& apt update -y \
&& apt install -y tzdata software-properties-common \
&& add-apt-repository --yes --update ppa:ansible/ansible \
&& apt install -y software-properties-common \
&& add-apt-repository --yes --update ppa:ansible/ansible \
&& apt install -y ansible
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment