esl / release_poller

3 stars 2 forks source link

[feature] docker build tooling #10

Closed sescobb27 closed 6 years ago

sescobb27 commented 6 years ago

** Usage

path = "/Users/kiro/workspace/elixir/elixir-docker-guide"
{ctx, _} = 
  Path.join([path, "Dockerfile"])
  |> DockerApi.DockerfileParser.parse()
  |> DockerApi.DockerBuild.build(path)
sescobb27 commented 6 years ago

While trying to bind-mount a host directory to a container work I tried to make it work using the official docker client without success, here are the steps i used

# https://github.com/docker/docker-py
# python2.7
# https://docker-py.readthedocs.io/en/1.4.0/volumes/

from docker import Client
c = Client(base_url='unix://var/run/docker.sock')
host_config = c.create_host_config(binds=['/Users/kiro/test:/data'])
container_id = c.create_container('busybox:1.29', 'ls /data', volumes=['/data'], host_config=host_config)
c.commit(container_id)

Then with the ImageId returned from c.commit(container_id) i ran it with docker run -it ImageId /bin/bash and then run ls /data but the directory is empty and it shouldn't be empty

sescobb27 commented 6 years ago

it seems we can create a container with the mounted directory but we can't create an image with that mounted directory. https://github.com/moby/moby/issues/6999

NOTE: yes, that seems to be the issue. the steps to reproduce are the same as the steps above but instead of commiting the container and running it, I just ran docker start -ai ContainerId

screen shot 2018-09-24 at 1 18 16 pm
ghost commented 6 years ago

It may be the case that having mounted that directory - and run a command, and generated an image, you will need to mount that directory when you create a container from that image in order to run subsequent commands. If it were a (pseudo) dockerfile/build it would look something like this.

ghost commented 6 years ago

+1

ghost commented 6 years ago
screen shot 2018-09-25 at 10 30 48 am
sescobb27 commented 6 years ago

closing this PR in favor of https://github.com/sescobb27/ex_docker_build