首次使用docker
勉强前的印象
虽然知道,但从未接触过,而且一开始似乎很难…
Docker的安装和配置
- インストール
yum update
yum search docker
yum install -y docker
- dockerの起動・自動起動設定
systemctl start docker
systemctl enable docker
- バージョン確認
docker -v
尝试配置Ubuntu环境
- ubuntuのコンテナを検索
docker search ubuntu
==========
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/ubuntu Ubuntu is a Debian-based Linux operating s... 11721 [OK]
docker.io docker.io/dorowu/ubuntu-desktop-lxde-vnc Docker image to provide HTML5 VNC interfac... 487 [OK]
docker.io docker.io/websphere-liberty WebSphere Liberty multi-architecture image... 266 [OK]
docker.io docker.io/rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 250 [OK]
docker.io docker.io/consol/ubuntu-xfce-vnc Ubuntu container with "headless" VNC sessi... 231 [OK]
docker.io docker.io/ubuntu-upstart Upstart is an event-based replacement for ... 110 [OK]
docker.io docker.io/neurodebian NeuroDebian provides neuroscience research... 78 [OK]
docker.io docker.io/1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 50 [OK]
docker.io docker.io/ubuntu-debootstrap debootstrap --variant=minbase --components... 44 [OK]
docker.io docker.io/open-liberty Open Liberty multi-architecture images bas... 42 [OK]
docker.io docker.io/i386/ubuntu Ubuntu is a Debian-based Linux operating s... 24
docker.io docker.io/nuagebec/ubuntu Simple always updated Ubuntu docker images... 24 [OK]
docker.io docker.io/1and1internet/ubuntu-16-apache-php-5.6 ubuntu-16-apache-php-5.6 14 [OK]
docker.io docker.io/1and1internet/ubuntu-16-apache-php-7.0 ubuntu-16-apache-php-7.0 13 [OK]
docker.io docker.io/1and1internet/ubuntu-16-nginx-php-phpmyadmin-mariadb-10 ubuntu-16-nginx-php-phpmyadmin-mariadb-10 11 [OK]
docker.io docker.io/1and1internet/ubuntu-16-nginx-php-5.6-wordpress-4 ubuntu-16-nginx-php-5.6-wordpress-4 8 [OK]
docker.io docker.io/1and1internet/ubuntu-16-apache-php-7.1 ubuntu-16-apache-php-7.1 6 [OK]
docker.io docker.io/1and1internet/ubuntu-16-nginx-php-7.0 ubuntu-16-nginx-php-7.0 4 [OK]
docker.io docker.io/pivotaldata/ubuntu A quick freshening-up of the base Ubuntu d... 4
docker.io docker.io/pivotaldata/ubuntu16.04-build Ubuntu 16.04 image for GPDB compilation 2
docker.io docker.io/1and1internet/ubuntu-16-php-7.1 ubuntu-16-php-7.1 1 [OK]
docker.io docker.io/1and1internet/ubuntu-16-sshd ubuntu-16-sshd 1 [OK]
docker.io docker.io/pivotaldata/ubuntu-gpdb-dev Ubuntu images for GPDB development 1
docker.io docker.io/smartentry/ubuntu ubuntu with smartentry 1 [OK]
docker.io docker.io/pivotaldata/ubuntu16.04-test Ubuntu 16.04 image for GPDB testing 0
==========
- dockerコンテナをダウンロード
使用命令 docker pull 图像名称
docker pull ubuntu
==========
[root@localhost ~]# docker pull ubuntu
Using default tag: latest
Trying to pull repository docker.io/library/ubuntu ...
latest: Pulling from docker.io/library/ubuntu
83ee3a23efb7: Pull complete
db98fc6f11f0: Pull complete
f611acd52c6c: Pull complete
Digest: sha256:703218c0465075f4425e58fac086e09e1de5c340b12976ab9eb8ad26615c3715
Status: Downloaded newer image for docker.io/ubuntu:latest
==========
- ダウンロードしてきたイメージを確認
docker images
==========
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/ubuntu latest f63181f19b2f 34 hours ago 72.9 MB
==========
- dockerコンテナの実行
命令使用 docker run 选项 图像ID
图像ID 是在上面输出的,为 f63181f19b2f。
选项为 -it,在终端上可以进行操作。
docker run -it f63181f19b2f
==========
[root@localhost ~]# docker run -it f63181f19b2f
root@04632dddfde1:~# cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
root@04632dddfde1:~#
==========
- コンテナから抜ける
可以通过“退出”来退出。
root@04632dddfde1:~# exit
exit
[root@localhost ~]#
- dockerの状態を確認
docker ps -a
==========
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
04632dddfde1 f63181f19b2f "/bin/bash" 6 minutes ago Exited (0) 4 minutes ago naughty_keller
==========
- dockerを停止
您可以使用docker stop命令通过容器ID停止容器。
docker stop 04632dddfde1
==========
[root@localhost ~]# docker stop 04632dddfde1
04632dddfde1
==========
勉强后的印象 de
我只能安装并运行容器,但可能会简单得出乎意料吧?下一步我想在容器上尝试一些其他的东西。
请参考
-
- はじめての Docker
-
- 【初心者向け】DockerでCentOS7の環境を構築しよう!
- CentOS7にdocker環境を作る