Docker is a computer program that performs operating-system-level virtualization, also known as "containerization".
#1 Publish nginx server container with a single command:
Executing the above command does the following:
- Downloads image ‘nginx; from docker hub
- Starts a new container from that image
- Opens port 80 on the host IP
- Routes that traffic to the container IP, port 80
#2 Running a container in the background:
Executing the above command runs nginx server in the background, detach option tells Docker to run the container in the background.
#3 List all running containers
The above command lists all the containers in docker and their status.
#4 Stop a container
The containerID can be obtained using ls list all containers command. The container ID can be few digits, just enough for it to be unique.
#5 Run new container with specified name
A new container with nginx web server image is started with the name linuxhost.
#6 View container logs
The above command displays logs for the container name specified. The container name can be obtained using the ls list all containers command.
#7 View processes running within a container
This command lists all the processes running within the container by container name. The container name can be obtained using the ls list all containers command.
#8 List all commands using help command
This command lists all of the commands we can perform on a container.
#9 List all containers
This command lists all the containers with any status within docker.
#10 Remove containers by container IDs
This command removes all non-running container ID's specified seprated by space.
#11 Force remove running container
The -f option to rm command allows removing of a running container in docker.
#12 Remove all containers with a wildcard alternative
This command stops all containers first and then removes all of them. On Windows 10 use powershell instead of command prompt and the above command will work.