Maybe it works! Let's get started with Docker!

Introduction

This article is a memo when installing Docker. I will describe from the installation method of Docker to the simple operation confirmation of Docker.

Installation environment

macOS Catalina Version 10.15.6

Installation procedure

  1. Download from Docker official website. Press [Get Started] on the official website. スクリーンショット 2020-10-09 23.25.21.png
  2. Press [Download for Mac] on Docker Desktop. スクリーンショット 2020-10-09 23.26.00.png
  3. Open the downloaded Docker.dmg and drag and drop Docker.app to ʻApplications`. スクリーンショット 2020-10-09 23.56.38.png
  4. Double-click Docker.app from the application folder to start it. At this time, you may be asked about the authentication settings, so answer as asked.
  5. When the whale mark Docker icon appears on the menu bar, installation is complete! スクリーンショット 2020-10-10 0.06.10.png

Container operation

Docker is operated in the terminal, and all use the docker command.

Start and check the container

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.

Stop container

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

Delete container

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.

Image list

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

Image deletion

$ docker rmi nginx:1.19.3

Create and share images in containers

Next, let's create and share an image in a container. → Maybe it works! Create an image with Docker and share it!

Recommended Posts

Maybe it works! Let's get started with Docker!
Get started with DynamoDB with docker
Let's get started with parallel programming
Maybe it works! Create an image with Docker and share it!
Maybe it works! Display HTML page from nginx with Docker!
Let's get started with Java-Create a development environment ②
Let's get started with Java-Create a development environment ①
Getting Started with Docker
Get started with Gradle
Get started with Spring boot
How to get started with Gatsby (TypeScript) x Netlify x Docker
How to get started with slim
[Google Cloud] Getting Started with Docker
Getting Started with Docker with VS Code
I tried to get started with WebAssembly
[Now] Let's Redmine with Docker Compose with Let's Encrypt
[Note] How to get started with Rspec
Rails beginners tried to get started with RSpec
Experienced Java users get started with Android application development
I tried to get started with Spring Data JPA
Get started with "Introduction to Practical Rust Programming" (Day 3)
How to get started with creating a Rails app
Get started with serverless Java with the lightweight framework Micronaut!