0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

エセイー(エセSE)が挑戦する、初めてのDocker

Last updated at Posted at 2020-03-16

下記サイトに基本的な使い方は書いてある。
https://qiita.com/kariyaitaru/items/83fe1c8c9ed4f8732a63

下記サイトを参考に、dockerhubよりデータを取得する。
https://kitsune.blog/docker-install

docker run -d -p 8080:80 --name nginx nginx

nginxにアクセスする。

http://localhost:8080

上記コンテナを停止・起動する。

# コンテナを停止
$ docker stop nginx
nginx

# コンテナを起動
$ docker start nginx
nginx

次に、コンテナからイメージを作成してみる。以下は「https://kitsune.blog/docker-comman」を参照している。

  1. Dockerベースイメージの取得
  2. Dockerコンテナの起動
  3. Dockerコンテナに変更を加える
  4. Dockerイメージの作成

Dockerイメージの確認

C:\Users\XXXXX>docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              6678c7c2e56c        11 days ago         127MB

Docker Hubからベースイメージを検索するには、「docker search」コマンドを実行します。

C:\Users\XXXXX>docker search centos
NAME                               DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
centos                             The official build of CentOS.                   5884                [OK]             
ansible/centos7-ansible            Ansible on Centos7                              128                                     [OK]
jdeathe/centos-ssh                 OpenSSH / Supervisor / EPEL/IUS/SCL Repos - …   114                                     [OK]
consol/centos-xfce-vnc             Centos container with "headless" VNC session…   111                                     [OK]
centos/mysql-57-centos7            MySQL 5.7 SQL database server                   71                                   
imagine10255/centos6-lnmp-php56    centos6-lnmp-php56                              58                                      [OK]
tutum/centos                       Simple CentOS docker image with SSH access      45                                   
centos/postgresql-96-centos7       PostgreSQL is an advanced Object-Relational …   43                                  
kinogmt/centos-ssh                 CentOS with SSH                                 29                                      [OK]
pivotaldata/centos-gpdb-dev        CentOS image for GPDB development. Tag names…   11                                  
guyton/centos6                     From official centos6 container with full up…   10                                      [OK]
nathonfowlie/centos-jre            Latest CentOS image with the JRE pre-install…   8                                       [OK]
drecom/centos-ruby                 centos ruby                                     6                                       [OK]
centos/tools                       Docker image that has systems administration…   6                                       [OK]
pivotaldata/centos                 Base centos, freshened up a little with a Do…   4                                   
darksheer/centos                   Base Centos Image -- Updated hourly             3                                       [OK]
mamohr/centos-java                 Oracle Java 8 Docker image based on Centos 7    3                                       [OK]
pivotaldata/centos-mingw           Using the mingw toolchain to cross-compile t…   3                                   
pivotaldata/centos-gcc-toolchain   CentOS with a toolchain, but unaffiliated wi…   3                                   
miko2u/centos6                     CentOS6 日本語環境                                   2                                       [OK]
indigo/centos-maven                Vanilla CentOS 7 with Oracle Java Developmen…   1                                       [OK]
blacklabelops/centos               CentOS Base Image! Built and Updates Daily!     1                                       [OK]
pivotaldata/centos6.8-dev          CentosOS 6.8 image for GPDB development         0                                    
pivotaldata/centos7-dev            CentosOS 7 image for GPDB development           0                                    
smartentry/centos                  centos with smartentry                          0                                       [OK]

コンテナをダウンロードするには「docker pull OS名:バージョン」とする(:バージョンは省略可能)。今回は「docker pull centos:7」を実行する。

C:\Users\XXXXX>docker pull centos:7
7: Pulling from library/centos
ab5ef0e58194: Pull complete
Digest: sha256:4a701376d03f6b39b8c2a8f4a8e499441b0d567f9ab9d58e4991de4472fb813c
Status: Downloaded newer image for centos:7
docker.io/library/centos:7

docker images」でイメージを確認する。

C:\Users\XXXXX >docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              6678c7c2e56c        11 days ago         127MB
centos              7                   5e35e350aded        4 months ago        203MB

Dockerコンテナの一覧確認

Dockerコンテナの一覧確認は下記コマンド。

  • 起動中のコンテナのみを表示する: docker ps
  • 停止中のコンテナも表示する:docker ps -a

docker fileを作成する。
https://kitsune.blog/dockerfile-summary

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?