Docker is a containerization software. Docker containers are more lightweight than virtual machines since the containers run on the host kernel—a Docker container must be running the same OS as its underlying host (in case of Windows, WSL2 or Hyper-V is used). Docker and other containerization technologies are often used to distribute reproducible builds / configurations of software.
- To build an image from a Dockerfile, run
docker build . [-t <name>]
. To use the image without naming it, rundocker build . -q
which outputs a SHA256 ID. - To list images, run
docker image ls
- To create a container from an image, run
docker run -it <image-name-or-id>
- To list containers, run
docker ps -a
ordocker container ls -a
- To execute a command in a running container, run
docker exec -it <container-name-or-id> <command...>
Docker Desktop basic troubleshooting (e.g., container won’t turn on):
- Check if WSL integration turned off when it was turned on before.
- Try quitting Docker Desktop, run
wsl --shutdown
, and start Docker Desktop again. - Try restarting your computer.