Note: use phusion/baseimage instead of ubuntu
boot2docker init
boot2docker start
export DOCKER_HOST=tcp://$(boot2docker ip 2>/dev/null):2375
# warn: if you have multiple open shells, make sure to export the DOCKER_HOST variable in every one as the docker command use it to communicate with the minimal linux VM.
# to get the VM IP
boot2docker ip
# download an image from the hub and run a command into it
docker run ubuntu echo "hello world"
# get an interactive shell to the image
docker run -t -i ubuntu /bin/bash
# run a daemon. this returns a process SHA
docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"
# check processes
docker ps
docker logs [-f] [SHA]
docker stop [SHA]
-d
: run detached-P
: expose all open ports-p 6000:5000
: expose container port 6000 to local port 5000--name webapp
: explicitly name this container
docker search django
: search imagesdocker pull django
: fetch locally
Run an interactive shell (-t -i
), then exit, then commit the changes :
docker commit -m 'commit message' [SHA] username/newimage:v2
Create a new folder with a Dockerfile
(full reference)
example file :
FROM phusion/baseimage
MAINTAINER Julien Bouquillon <julien@revolunet.com>
RUN apt-get -qq update
RUN apt-get -qqy install mpg123 vlc
Build the new image : docker build -t="username/mydebian:v1" .
There is a workaround that enables mounting anything in /Users
:
- replace
~/boot2docker/boot2docker.iso
with http://static.dockerfiles.io/boot2docker-v1.1.2-virtualbox-guest-additions-v4.3.12.iso boot2docker stop
- `VBoxManage sharedfolder add boot2docker-vm -name home -hostpath /Users``
boot2docker start
Now you can use -v
to mount local folders to your containers !
(More details in this blogpost : https://medium.com/boot2docker-lightweight-linux-for-docker/boot2docker-together-with-virtualbox-guest-additions-da1e3ab2465c)
docker ps -a | grep "Exit" | awk '{print $1}' | while read -r id ; do
docker rm $id
done