This article is a memo when installing Docker. I will describe from the installation method of Docker to the simple operation confirmation of Docker.
macOS Catalina Version 10.15.6
Docker.dmg
and drag and drop Docker.app
to ʻApplications`.
Docker.app
from the application folder to start it.
At this time, you may be asked about the authentication settings, so answer as asked.Docker
icon appears on the menu bar, installation is complete!
Docker is operated in the terminal, and all use the docker
command.
To check the operation of Docker, start the nginx
container, which is a web server published on Docker Hub (Docker version of Git Hub).
Use the docker run
command to start the container.
$ docker run nginx:1.19.3
Initially there was no container image locally, so get the image and it will be displayed as below.
Unable to find image 'nginx:1.19.3' locally
1.19.3: Pulling from library/nginx
d121f8d1c412: Pull complete
66a200539fd6: Pull complete
e9738820db15: Pull complete
d74ea5811e8a: Pull complete
ffdacbba6928: Pull complete
Digest: sha256:fc66cdef5ca33809823182c9c5d72ea86fd2cef7713cf3363e1a0b12a5d77500
Status: Downloaded newer image for nginx:1.19.3
With Docker running, use the docker ps
command from another terminal to confirm that the nginx
container has started.
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
51d72c08c122 nginx:1.19.3 "/docker-entrypoint.…" 3 minutes ago Up 3 minutes 80/tcp gracious_lalande
You can see that version 1.19.3 of nginx
is running with the ID 51d72c08c122
.
Execute by specifying the CONTAINER ID
obtained by the docker ps
command.
$ docker stop 51d72c08c122
Check with the docker ps
command.
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
You can confirm that there is no running container ID.
By the way, if you specify the container ID in the docker start
command, you can start the same container again.
$ docker start 51d72c08c122
To delete a container, stop the container, specify the container ID, and use the docker rm
command.
$ docker rm 51d72c08c122
After processing, if you specify the container ID earlier in the docker start
command and start it,
$ docker start 51d72c08c122
error during connect: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.40/containers/51d72c08c122/start: EOF
Error: failed to start containers: 51d72c08c122
An error that the start of the corresponding container ID failed is returned, and it can be confirmed that the container has been deleted.
You can display a list of images on the local host with the docker images
command.
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx 1.19.3 992e3b7be046 3 days ago 133MB
$ docker rmi nginx:1.19.3
Next, let's create and share an image in a container. → Maybe it works! Create an image with Docker and share it!
Recommended Posts