I'm trying to build a bunch of dockers on a machine using Ansible's docker_image module.
I build 1 "base" docker image, which is used as the FROM image in all subsequent dockers images. This works when issuing the build commands manually as:
sudo docker build -t base .
sudo docker build -t postgres .
But when I try to do the same with the Ansible module the second image (and all subsequent images that uses the "base" image) fails with the following error:
TASK: [Docker | Build postgres] ************************************
failed: [192.168.1.120] => {"changed": true, "failed": true, "image_id": null}
msg: Error: Error: image base:latest not found
Log:Step 0 : FROM base
FATAL: all hosts have already failed -- aborting
The entries in my Playbook is:
- name: Docker | Build base
docker_image: path="/home/xx/data/dockers/base/" name="base" state=present
- name: Docker | Build postgres
docker_image: path="/home/xx/data/dockers/postgresql/" name="postgres" state=present
When it fails the "base" image exists on the machine and I can verify it by checking docker images
. The follow up images (in this case postgres) also builds without fail when doing a manual build.
Relevant extracts from the Dockerfiles:
Base Dockerfile:
FROM ubuntu
MAINTAINER me
RUN apt-get update
RUN apt-get install -y \
software-properties-common \
wget \
git \
unzip \
nano \
vim-tiny
CMD bash
Postgres Dockerfile:
FROM base
MAINTAINER me
RUN groupadd -r postgres && useradd -r -g postgres postgres
...
So Ansible struggles to build an image using another image as a base image. I'm sure that the issue isn't with the Dockerfiles because I can build the images manually. I'm just trying to automate the build with Ansible and that's giving me the issue.
Any advice?