...What's my container id?
...Port forwarding or redirection
...Running an interactive container
...Virtualize MAC address
...Launching a server automatically
Docker file
Backup and restore
This page gathers information concerning the use of Docker


  • A container is an instance of an image (e.g running image)


Currently, on Linux mint, don't use the apt-get package, but the installation procedure on the Docker page. To be able to run docker as a user:
sudo usermod -aG docker axelle
Then unlog/relog.


  • docker images: shows all existing images on your host
  • docker search: to search for (public) images:
    docker search --stars=10 debian
  • docker pull: to download a given image:
    docker pull docker/whalesay
  • docker run: to run a given image (-> container):
    $ docker run hello-world
  • docker ps: list all running containers. If you specify docker ps -a, you'll list all containers even those which have exited.
  • docker stop container: stops a container
  • docker rmi: removes an image. For example:
    docker rmi -f tag
  • docker logs container: view logs of the container. Add -f to follow the flow of logs
  • docker inspect container: view the configuration of a given image or container

What's my container id?

If you are running an interactive shell in the container, then the container id shows in the prompt:
root@deffbaefb43f <- that's the container id
You can also get the id with docker ps -a.


Copying a file to the container

cp thefile.txt /var/lib/docker/devicemapper/mnt/123abc/rootfs/root 

Creating a data container

The following container merely creates two directories in which data will be held:
docker create -v /usr/src/redmine/config -v /usr/src/redmine/files --name redmine-data redmine /bin/true

Port forwarding or redirection

In this case, the container redirects port 9000 to 8000 to the external world:
$ docker run -d -p 8000:9000 ...
If there are several ports to redirect, add as many -p directives. If the port should not redirected, but still open: -p 9000:9000 for example.

Running an interactive container

It's the -i option in docker run. The typical command which is very much used is:
docker run -t -i container /bin/bash
The -t gets a tty. And this command will get an interactive shell in the container. You can also use:
docker exec -it container bash

Virtualize MAC address

$ docker run -d ... --mac-address="00:11:22:33:44:55" blah/blah

Launching a server automatically

When launched with "docker run", a container exits as soon as the command returns. If we want the container to remain alive, the idea is to launch the container with a command that does not return. To do so, a solution is to use "supervisord":
sudo apt-get install supervisor
Then in /etc/supervisor/conf.d, create a configuration file for the service to launch:
and in /etc/supervisor/supervisor.conf, add:
Then, you should refresh supervisor:
$ supervisorctl reread
$ supervisorctl update
Check your service runs ok:
$ supervisorctl
If not, check the logs. Then, run your docker container like:
$ docker run -d ... container /usr/bin/supervisord

Docker file

ROM debian:wheezy
RUN apt-get update 
COPY nginx.conf /etc/nginx/nginx.conf
RUN chmod 744 /home/docker/script/service_start.sh
ENTRYPOINT /home/docker/script/service_start.sh
WORKDIR /home/docker
The ENTRYPOINT is to start when the container starts.


docker build -t name .


To backup an image:
$ docker save -o ~/container1.tar container1
To restore:
$ docker load -i /container1.tar
To backup a container, the idea is to perform a commit:
$ docker commit container-id name

Interesting images

  • debian