It is a persistent process that manages containers, and the Docker daemon manages the start, restart, and stop of containers by executing commands from users using Docker commands.
Docker Hub Docker image registry service. You can publish, search, and download Docker images.
A file system that collects the files required to execute a container. A special file system such as AUSF is used. The data on the image is composed of layers and is read-only.
% docker images
## %docker tag Original image name New image name % docker tag docker/whalesay my_whalesay ## %docker tag Original image name New image name:tag % docker tag docker/whalesay my_whalesay:num1
In the case below, the image "my_whalesay" with the tag name "num1" is created.
## %docker inspect Target image or image ID % docker inspect my_whalesay
## %docker rmi Target image or image ID % docker rmi docker/whalesay
## docker rmi -f Target image or image ID % docker rmi -f docker/whalesay
## %docker pull Image you want to get % docker pull docker/whalesay
The latest may not be a new image, so see the official for details.
Dockerfile Image definition file. Building an image from a Dockerfile is called an image build.
##FROM specifies the original image when creating the image This time docker/whalesay:latest FROM docker/whalesay:latest ##RUM specifies commands when building images RUN apt-get -y update && apt-get install -y fortunes ##CMD is an instruction that specifies a command to execute after the container is created CMD /usr/games/fortune | cowsay
## % docker build -t image name. % docker build -t docker-whale .
-t gives the built image a name This time docker -whale. "." Indicates the directory and file range that can be accessed when creating an image in the build context settings. This time it shows the current directory. (Period).
## % docker build --no-cache -t image name. % docker build --no-cache -t docker-whale .
When the above image is built again with Dockerfile, the cache is applied and it is not updated. A command that prevents new packages from being installed. It can be updated without using the cache.
% docker login Username Docker Hub username Password:Docker Hub password
If successful, "Login Succeeded" will be displayed.
## %docker tag Original image name Repository name:Tag name % docker tag docker-whale user/docker-whale:num1
Since it pushes to the repository "user / docker-whale" of Docker Hub, it becomes such a description. If no tag name is specified, it will be the latest tag. Note that if you make a mistake in the repository name, you will not be able to push!
## %docker push repository name:Tag name % docker push user/docker-whale:num1
If you get an error here, check again if the repository name matches. Make sure the image is pushed to the Docker Hub repository.
## %docker pull image name:Tag name % docker pull user/docker-whale:num1
Confirm that the image is pulled with the docker images command.
## % docker run --name container name-d -p Host side port number:Container port number Image name % docker run --name some-nginx -d -p 8080:80 some-content-nginx
--neme is an option to name the container to start. -d runs the container in the background in detach mode. If there is no input, other operations will not be possible on the executed screen, so it is recommended to enter it. -p is an option to set the container's port outside the container. Here, the port number that 8080 exposes to the outside. If it runs normally, you can see that nginx is running at http: // localhost: 8080 /.
##View running containers % docker ps ##Displaying containers that are running or stopped % docker ps -a
##docker start container name or container ID % docker start static-site
The status of the container changes to running.
##docker pause container name or container ID % docker pause static-site
The status of the container changes to paused.
##docker unpause container name or container ID % docker unpause static-site
The status of the container changes to running.
##docker restart container name or container ID % docker restart static-site
The status of the container goes through restarting and becomes running.
##docker rm container name or container ID % docker rm static-site ##
Note that you cannot delete it unless you stop the container!
## docker rm -f Container name or container ID % docker rm -f static-site
Used when the container cannot be deleted.
You can check the status of the container with the docker ps command or the docker inspect command.
created </ b> ・ ・ ・ A container is created by docker create, and it is in the state before start. It changes to running with docker start. running </ b> ・ ・ ・ The container is running. Paused with the docker pause command, exited with the docker stop command, restarting with the docker restart command, and then running. paused </ b> ・ ・ ・ No response even if you connect to a running container in a suspended state or make a request. Return to running state with docker unpause command. restarting </ b> ・ ・ ・ The container is being restarted and will be restarted immediately, so you cannot see much. When the reboot is finished, it will be running. exited </ b> ・ ・ ・ The container has been closed and remains. Basically, you can delete the container from here with the docker rm command. dead </ b> ・ ・ ・ Displayed when the container remains without being terminated normally. If this happens, there is no choice but to delete it.
##docker commit container name or container ID image name:Tag name % docker commit static-site static-site:ver1
You can save the state of the container as an image. However, since the work done in the container is not recorded as a clear record, it is usually described in the Dockerfile and the history is recorded.
##docker history image name or image ID % docker history docker-whale
You can check the history of docker-whale.