Docker cheatsheet.
-
To get the list of commands:
$ docker
-
To search for images in docker index:
$ docker search tutorial
-
To pull the image:
$ docker pull learn/tutorial
-
To run a command in contained environment:
$ docker run learn/tutorial echo "hello world"
-
To install a new program:
$ docker run learn/tutorial apt-get install -y ping
-
To list containers(Get container id from here):
$ docker ps -l
-
To list running containers:
$ docker ps
-
To make your changes persist. New layer
$ docker commit [OPTIONS] CONTAINER_ID REPOSITORY
-
Inspect container to get more details:
$ docker inspect CONTAINER_ID
-
Keep stdin open (-i) and allocate a pseudo-tty (-t)
$ docker run -i -t learn/tutorial /bin/bash
-
You may need to enable ipv4 forwarding before using docker on virtual box.
In
/etc/sysctl.config
file add the following line.net.ipv4.ip_forward = 1
Run
sysctl -p /etc/sysctl.conf
to make the changes permanent.