Maybe it works! Create an image with Docker and share it!

Introduction

This article describes how to create a simple container image with Docker and share it with Docker Hub. Since this is a beginner's article, I would appreciate it if you could point out any mistakes.

environment

Prerequisites

You have Docker installed. If you have not installed it, please install it by referring to the link below. Maybe it works! Let's get started with Docker!

Build container image

In order to create a container image, you need to create a Dockerfile that is the contents of the container. Write the following code and save it as Dockerfile.

Docekrfile


FROM ubuntu:20.04
CMD ["echo", "hello Docker!!"]

The content of the code calls the operating system ʻubuntuand outputshello Docker !!`.

In your terminal, go to the Dockerfile directory and hit the docker build command.

$ docker build -t hellodoc .

The -t option allows you to specify an image name. . Indicates the path where the Dockerfile is located. It's . because I'm typing the command in the directory where the Dockerfile is located.

After the build process is finished, try moving the container image.

$ docker run hellodoc
hello Docker!!

It worked fine!

You can see the list of local container images with the docker images command.

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hellodoc            latest              32d0a84555ac        2 weeks ago         72.9MB

Sharing container images

If you can confirm the operation of the container image, it will just display ~~ hello Docker !! ~~ Let's share the container image with Docker Hub.

Register with Docker Hub

As you can see from the name, Docker Hub is like Docker of Git Hub (personal recognition), and various container images are published.

If you don't have a Docker Hub account, go to the Docker Hub sign-up page (https://hub.docker.com/signup/) and sign up.

Log in to Docker Hub from your terminal.

$ docker login -u ■■■■■■■■■
Password: ************
Login Succeeded

Enter the registered user account in ■ and the password in *.

Sharing container images

Build in a format for sharing container images.

docker build -t ■■■■■■■■■/hellodoc:1.0.0 .

There is a rule in the image name naming convention for sharing.

Register the container image with the docker push command.

$ docker push ■■■■■■■■■/hellodoc:1.0.0

Let's check with Docker Hub when the process is finished. スクリーンショット 2020-10-10 17.24.17.png You are registered properly!

Download container image

The registered container image can be downloaded locally with the docker pull command.

docker pull ■■■■■■■■■/hellodoc:1.0.0

Recommended Posts

Maybe it works! Create an image with Docker and share it!
Maybe it works! Let's get started with Docker!
2. Create Docker image and register Registry
Maybe it works! Display HTML page from nginx with Docker!
Image Spring Boot app using jib-maven-plugin and start it with Docker
Create a Docker Image for redoc-cli and register it on Docker Hub
Create an infinite scroll with Infinite Scroll and kaminari
Create jupyter notebook with Docker and run ruby
[Swift] Create an image selection UI with PhotoKit
Create an EC site with Rails5 ④ ~ Header and footer ~
Create an E2E test environment with Docker x Cypress
Build an Android image for Orange Pi 4 with Docker
Create a Java (Gradle) project with VS Code and develop it on a Docker container
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (5)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (6)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (3)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (2)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (1)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (4)
Create a Java (Maven) project with VS Code and develop it on a Docker container
Create a Docker image with the Oracle JDK installed (yum
Make Docker confusing with Pokemon and make it easier to attach
Build Docker Image lightweight and fast with CodeBuild with Santa Banner
Post an image with POSTMAN
Create Rails5 and postgresql environment with Docker and make pgadmin available
Build Metabase with Docker on Lightsail and make it https with nginx
Create an app catalog site using CLI for Microsoft 365 with Docker
Docker Image creation for Keycloak extensions and performance testing with Gatling
Create a flyway jar with maven and docker build (migrate) with docker-maven-plugin
Use Jenkins to build inside Docker and then create a Docker image.
Create an immutable class with JAVA
Create a Vue3 environment with Docker!
Run lambda with custom docker image
Create a lightweight STNS Docker image
Create an app with Spring Boot 2
Hello World with Docker and C
Create SolrCloud verification environment with Docker
Create an excel file with poi
Create an app with Spring Boot
Create Laravel environment with Docker (docker-compose)
Share it with your Instagram story!
Restart apache with docker php-apache image
Microservices With Docker and Cloud Performance
Create an iOS shortcut app and quickly open the key with NFC
A shell script that builds a Docker image and pushes it to ECR
Create a program to post to Slack with GO and make it a container
Create an EC site with Rails5 ③-Set model associations and other things-
How to crop an image with libGDX
How to share files with Docker Toolbox
Let's create an instance with .new yourself. .. ..
[Java] Create an executable module with Gradle
Create a container image for arm64 of Kibana and register it in GitHub Container Registry. Start Elastic Stack with Docker Compose on Raspberry Pi 4 (64bit)
Building Rails 6 and PostgreSQL environment with Docker
Create Rails 6 + MySQL environment with Docker compose
Create a MySQL environment with Docker from 0-> 1
Create Spring Boot-gradle-mysql development environment with Docker
Proxy server with squid using docker image
[Docker] Create Node.js + express + webpack environment with Docker
Communicate Gitlab and Gitlab Runner launched with Docker
Allow image posting with [Docker + WordPress + MySQL]
Image flew when updating Docker with WSL2