Simulation “docker build -f” with ansible module “docker_image”

While I build docker image and I want to add the instruction “COPY” in Dockerfile with a directory which is outside of current build directory(place where Dockerfile is placed) – I’m using something like this:

docker build -f centos6-fresh/Dockerfile -t test/c6-fresh .

  • Issues getting Ansible to work with Boot2Docker
  • Docker \ how to pull only changed images
  • Is it possible to let ansible print each statement?
  • Docker Pull taking unexpectedly long time via Ansible
  • Network connection between 2 Docker Container (JBOSS/DATABASE)
  • Ansible docker module picks random port by default
  • Now I want to do provisioning containers and building docker images through ansible.
    Of course I’m able to do it with shell, command or raw modules, but I saw special module for Docker.

    So I’ve used module “docker_image”

    - name: Build test image
               path: /docker/build_env/test
               name: test_build
               tag: v0

    And certainly I’ve got the error.

    Is there any option, to set from which directory, building process must be started?

    The example of case where I need these manipulations:

    I have management node(my laptop) with ansible and Docker host with containers. Ansible dir is provisioning with git to Docker server.

    Usually I build an image in the directory build_env on the Docker host:

    [root@docker build_env]# ls -1

    So after run “git pull” in ansible directory, I run something like

    docker build -f centos6-fresh/Dockerfile -t test/c6-fresh .

    Dockerfile consists:

    COPY ansible /etc/ansible

    As we now, docker prevents to use something like “COPY ../ansible” in the COPY or ADD options.

  • Is there a way to prevent outside access to container memory
  • Can Docker be installed on SUSE 11 SP3
  • How safe is to use docker in production? [closed]
  • docker webpack compiled files missing when running
  • Can't deploy artifact to KIE-server via Drools workbench because of “ConversationId not valid - missing releaseId”
  • Docker & Rails | bundler: command not found: rails
  • One Solution collect form web for “Simulation “docker build -f” with ansible module “docker_image””

    According to the docker_image documentation, there is a dockerfile option that is an exact analog to the -f command line option. So you would just need:

    - name: Build test image
        path: /docker/build_env/
        name: test_build
        tag: v0
        dockerfile: centos6-fresh/Dockerfile
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.