Docker is similar to VMWare Workstation and Oracle VM VirtualBox. It enables host operating system (for example, Windows) to run guest operating system(s) on top of it.
Docker requires you to enable Hyper-V on Windows 10 Pro, while VirtualBox requires you to disable Hyper-V on Windows 10 Pro, so you cannot run both virtualization technology on the same OS.
Docker is widely preferred because of its efficiency in using computer resources.
- List all images
docker images -a
- Remove an image
docker rmi
- List all containers
docker ps -a
docker container ls -a
- Pull an image
docker pull
: docker pull ubuntu:latest
- Run a container
docker run -d -it --name
docker run -d -it --name myubuntu ubuntu
- Stop a container
docker stop
- Remove a container
docker rm
- Attach to a running container
docker attach
- Commit a container (save it as an image)
docker commit
- Execute command
docker exec
docker exec myubuntu bash -c "ls -aF /home; cat /etc/passwd"
- Expose container ports to host
docker run -it -d -p
: docker run -it -d -p 9100:9100 -p 9090:9090 --name mycentos centos