Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly.
Basics Link to heading
- Container - isolated processe for each of your app’s components. Each component runs in its own isolated environment, completely isolated from everything else on your machine.
- Image - a standardized package that includes all of the files, binaries, libraries, and configurations to run a container.
- Registry - a centralized location for storing and sharing your container images. It can be either public or private.
- Docker Engine - an open source containerization technology for building and containerizing your applications.
- Docker Compose - a tool for defining and running multi-container applications. you can define all of your containers and their configurations in a single YAML file.
- Docker Desktop - a one-click-install application for your Mac, Linux, or Windows environment that lets you build, share, and run containerized applications and microservices.
- Docker Hub - the world’s largest container registry for storing, managing, and sharing Docker images.
- Docker Scout - a solution for proactively enhancing your software supply chain security.
Cheat Sheet Link to heading
Start a container Link to heading
- docker run -d -p host-port:container-port docker/name-of-image
- e.g. docker run -d -p 8080:80 docker/welcome-to-docker
Check status of running containers Link to heading
- docker ps
Stop a container Link to heading
- docker stop the-container-id
- e.g. docker stop 8884ac2aad34
Build an image with tag Link to heading
- docker build -t tag-name path
- e.g. docker build -t myapp .
List all images Link to heading
- docker images
Delete a image Link to heading
- docker rmi the-image-id
- e.g. docker rmi c1f619b6477e
Get into a running container’s shell Link to heading
- docker exec -it container ID/Name sh
- e.g. docker exec -it b7a9f5eb6b85 sh (Ubuntu)
- e.g. docker exec -it b7a9f5eb6b85 /bin/ash (Alpine Linux)
Get Docker version Link to heading
- docker -v
Export image Link to heading
- docker image save -o archive-name.tar image-name:tag
- e.g. docker image save -o my-image.tar my-image:0.1.0
Import image Link to heading
- docker image load -i archive-name.tar
- e.g. docker image load -i my-image.tar