Docker basics

Mittwoch, 11. November 2015, 08:43 Uhr | roberto@vasquez-angel.de |

Build docker image from Dockerfile

docker build .

Tag image:

docker tag <hash> <organisation>/<image_name>:<version>

Push to dockerhub:

docker push <organisation>/<image_name>

List local docker images

docker images

Delete docker tag:

docker rmi <hash>

List running images/processes:

docker ps -l

Stop container:

docker stop <container_idsh>

Start container

docker start <hash>

Run an image and bash into it:

docker run -t -i <hash/image_name:tag> /bin/bash

Run a container with the current directory mounted int /app:

docker run -v $PWD:/app -it <hash/image_name:tag> /bin/bash

Docker and Rails

Bundle and run Rspec suite:

docker run --volume $PWD:/data --workdir /data -ti example/rails:2.0.2 /bin/bash -lc 'cd . && bundle install && bundle exec rspec'