-
Run a container with a default bash command.
docker container run -it --name container_name ubuntu bashdocker container run
[OPTIONS]--nameCONTAINER_NAMEubuntuCOMMAND -
Start an existing container with a default bash command.
docker container start -ai container_namedocker container start
[OPTIONS]--nameCONTAINER_NAME -
Exit an existing container from bash mode.
exit -
Execute a bash command on an existing container that is still in process.
docker container exec -it container_name bashdocker container exec
[OPTIONS]--nameCONTAINER_NAMECOMMAND
Build a Docker image from a Dockerfile.
docker image build -t yaronmiro/node:6.11.5-alpine .
docker image build [OPTIONS:TAG] => IMAGE_NAME DOCKERFILE_PATH
Run a Docker container process as background process on the CLI.
-d / --detach
docker container run -d
Display detailed information of a target container.
docker container inspect container_name => output a json format object of the container.
docker container inspect container_name --format '{{ .NetworkSettings.IPAddress }}' => Get the container IP Address.
Display a list of containers'{{ .NetworkSettings.IPAddress }}'
aliases => ps, list
docker container ls => Only list the current running continers.
docker container ls -a => List all of the existing continers on the machine.
Define a unique fixed name for the container process (Alternative identifier usage over a random genarated container ID).
-n / --name
docker container run --name container_name
Define the incoming connection from the host machine into the container by defining a port relationship.
-p / --publish
docker container run --publish 80:80 => Define a single port mapping.
docker container run --publish 80:80 --publish 3000:3000 => Define a multiple port mapping.
HOST_PORT : CONTAINER_PORT => Arguments description.
docker image prune -f => Removes all history images from build process (repository => <none>)
Remove one or more containers by specifing a single or multiple containers names or Ids.
rm
docker container rm container_name => Remove a single container.
docker container rm container_1 container_2 => Remove multiple containers.
docker container rm -f container_name => Remove by force a current running container.
Remove a container automatically after exit.
--rm
docker container run --rm -it --name container_name nginx bash
Display a live monitor of container preformance.
docker container stats => Displays a list of all the current running container stats.
docker container stats container_name => Displays a target container stats.
Create a taged image.
docker image tag image image_with_a_tag_name
Display the running processes inside the target container
docker container top container_name
Docker network commands.
docker network ls => List all networks
docker network inspect network_name => Get a JSON format network details.
docker network create my_app_net => Create a new docker network.
docker network connect --network may_app_net container name => Connect a target container to specific network.
docker network disconnect --network may_app_net container name => Disconnect a target container from specific network.
docker container run --network may_app_net ngnix => Run a new container that is attached to a specific network.
docker container exec -it container_A ping container_B => Test connection bwtween containers on the by using the ping command.
docker container run -d --name search_Two --network search_net --net-alias search elasticsearch:2 => Create a container with an alias DNS search
Download an image from docker hub.
pull
docker image pull image_name
Upload an image to docker hub.
push
docker image push image_name
-
docker volume ls=> get a list of all the volumes. -
docker volume inspect volume_name=> get a list of all the volumes. -
docker container run --name my_container -v db:/var/lib/postgresql/data=> Create a name binding for the volume.docker container run --name my_container -v [VOLUME_NAME]:[VOLUME_IMAGE_PATH] -
docker container run --name my_container -v project/app:/var/lib/postgresql/data=> Create a name binding for the volume.docker container run --name my_container -v [HOST_DIRECTORY_PATH]:[VOLUME_IMAGE_PATH] -
docker container inspect db_old=> Inspect a the section that points to the{{ .Mounts }}config.
docker kill $(docker ps -q) => KIll on the running docker process.
$ docker rm -v $(docker container ls -q -a) => Remove all of the containers.
$ docker rmi $(docker image ls -q) => Remove all the images.
$ docker rmi $(docker volumes ls -q) => Remove all the volumes.