Docker is an open source containerized platform that allows developers to package applications and their dependencies into a portable container. Containers can run in any Docker-enabled environment, which makes application deployment and management easier and more efficient.
1. Basic concepts of Docker
Before you dig deep into Docker, it is important to understand some basic concepts:
- container: Containers are lightweight, portable, and runtime environments that encapsulate applications and their dependencies. Containers use the kernel of the operating system, but are isolated from each other.
- Mirror: Mirror is a blueprint used to create containers. It contains all the files and environment configurations needed to run an application.
- Docker Daemon: Docker daemon is used to manage the life cycle of Docker containers.
- Docker CLI: Docker command line interface, allowing users to interact with Docker daemon.
2. Docker installation
2.1 Windows / macOS
- Download Docker Desktop: Access DockerOfficial websiteDownload Docker Desktop for your operating system.
- Install Docker Desktop: Double-click the downloaded installation package and follow the prompts to install it.
- Start Docker: After the installation is complete, start Docker Desktop.
2.2 Linux
On Linux, Docker can be installed through the package manager. Here are the steps to install Ubuntu:
# Update package indexsudo apt-get update # Install the necessary packagessudo apt-get install apt-transport-https ca-certificates curl software-properties-common # Add Docker's official GPG keycurl -fsSL /linux/ubuntu/gpg | sudo apt-key add - # Add a stable version of Dockersudo add-apt-repository "deb [arch=amd64] /linux/ubuntu $(lsb_release -cs) stable" # Update the package index againsudo apt-get update # Install Dockersudo apt-get install docker-ce
After the installation is completed, you can verify that Docker is installed successfully through the following command:
docker --version
3. Basic use of Docker
3.1 Pull the mirror
Use the following command to pull an image from the Docker Hub, e.g.hello-world
:
docker pull hello-world
3.2 Run the container
Run a container and execute the commands in it:
docker run hello-world
3.3 View running containers
View the currently running container:
docker ps
3.4 Stop the container
You can stop a running container using the following command:
docker stop <containerID>
3.5 Delete the container
Delete a stopped container:
docker rm <containerID>
3.6 List all images
View all Docker images locally:
docker images
This is the article about the basic concepts, installation steps and some simple usage of Docker. For more related docker installation steps, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!