1.
Virtualization
2. Containerization
Size ( lightweight )
Simplicity of use
3. Pulling Images from Docker Hub
docker pull wordpress
4. Manipulating containers
1. Creating
$ docker run -p 8080:80 wordpress
$ docker run -p 8080:80 -d wordpress ( called daemon
“Background” mode )
$ docker run -it openjdk ( called Interactive mode )
2. Viewing all running containers
$ docker ps
$ docker ps -a
3. Existing
Ctrl + D ==> Exit and stop container
Ctrl + P THEN Ctrl + Q ==> Exit ( MUST be in interactive mode )
==> exiting while keeping the container running in the
background
4. Stopping a running container
$ docker stop {container_id}
$ docker stop {container_name}
5. Attaching to a running container ( Must be started first )
$ docker attach {container_id}
$ docker attach {container_name}
6. Starting a stopped container
$ docker start {container_id}
$ docker start {container_name}
7. Deleting a container
$ docker rm {container_id}
$ docker rm {container_name}
$ docker container prune → Removes all stopped containers
5. Volumes
1. Creating
$ docker volume create {volume_name}
2. Viewing all running containers
$ docker volume ls
3. Inspecting a volume info.
$ docker volume inspect {volume_name}
$ docker volume inspect {volume_id}
4. Deleting a volume
$ docker volume rm {volume_name}
$ docker volume rm {volume_id}
5. Attaching a volume to a container
$ docker run -it -v {volume_name}:
{location_inside_container} {image_name}
$ docker run -it -v my_first_volume:/test_folder alpine
Bind-mounts
$ docker run -it -v {location_on_ host}:
{location_inside_container} {image_name}
$ docker run -it -v my_first_volume:/test_folder alpine