1. Home
  2. /
  3. Web technology
  4. /
  5. Ubuntu
  6. /
  7. [ Linux ] –...

[ Linux ] – 安裝 Docker on Ubuntu 18.04

評等結果
點擊便能為這篇文章進行評等!
[評等總次數: 0,平均評等: 0]

安裝 Docker on Ubuntu 18.04

指令:apt install docker.io

啟用docker

指令:systemctl start docker

設定開機自動啟動docker

指令:systemctl enable docker

Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable docker

systemctl指令說明
http://linux.vbird.org/linux_basic/0560daemons.php

查詢docker版本

指令:docker –version

Docker version 18.06.1-ce, build e68fc7a

查詢公開的docker映像檔

指令:docker search ubuntu

NAME DESCRIPTION STARS OFFICIAL AUTOMATED
ubuntu Ubuntu is a Debian-based Linux operating sys… 9107 [OK]
dorowu/ubuntu-desktop-lxde-vnc Ubuntu with openssh-server and NoVNC 264 [OK]
rastasheep/ubuntu-sshd Dockerized SSH service, built on top of offi… 198 [OK]
consol/ubuntu-xfce-vnc Ubuntu container with “headless” VNC session… 152 [OK]
ubuntu-upstart Upstart is an event-based replacement for th… 96 [OK]
ansible/ubuntu14.04-ansible Ubuntu 14.04 LTS with ansible 95 [OK]
neurodebian NeuroDebian provides neuroscience research s… 56 [OK]
1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 48 [OK]
ubuntu-debootstrap debootstrap –variant=minbase –components=m… 40 [OK]
nuagebec/ubuntu Simple always updated Ubuntu docker images w… 23 [OK]
tutum/ubuntu Simple Ubuntu docker images with SSH access 18
i386/ubuntu Ubuntu is a Debian-based Linux operating sys… 16
1and1internet/ubuntu-16-apache-php-7.0 ubuntu-16-apache-php-7.0 13 [OK]
ppc64le/ubuntu Ubuntu is a Debian-based Linux operating sys… 12
1and1internet/ubuntu-16-nginx-php-5.6-wordpress-4 ubuntu-16-nginx-php-5.6-wordpress-4 7 [OK]
eclipse/ubuntu_jdk8 Ubuntu, JDK8, Maven 3, git, curl, nmap, mc, … 7 [OK]
codenvy/ubuntu_jdk8 Ubuntu, JDK8, Maven 3, git, curl, nmap, mc, … 5 [OK]
darksheer/ubuntu Base Ubuntu Image — Updated hourly 5 [OK]
pivotaldata/ubuntu A quick freshening-up of the base Ubuntu doc… 2
1and1internet/ubuntu-16-sshd ubuntu-16-sshd 1 [OK]
smartentry/ubuntu ubuntu with smartentry 1 [OK]
paasmule/bosh-tools-ubuntu Ubuntu based bosh-cli 1 [OK]
1and1internet/ubuntu-16-healthcheck ubuntu-16-healthcheck 0 [OK]
pivotaldata/ubuntu-gpdb-dev Ubuntu images for GPDB development 0
ossobv/ubuntu Custom ubuntu image from scratch (based on o… 0

下載映像檔

指令:docker pull ubuntu

Using default tag: latest
latest: Pulling from library/ubuntu
38e2e6cd5626: Pull complete
705054bc3f5b: Pull complete
c7051e069564: Pull complete
7308e914506c: Pull complete
Digest: sha256:945039273a7b927869a07b375dc3148de16865de44dec8398672977e050a072e
Status: Downloaded newer image for ubuntu:latest

查詢本機映像檔

指令:docker images

REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 20bb25d32758 27 hours ago 87.5MB

創建一個容器

指令: docker create ubuntu:18.04

Unable to find image ‘ubuntu:18.04’ locally //本地端沒找到此映像檔
18.04: Pulling from library/ubuntu //從來源端拉一個下來
Digest: sha256:945039273a7b927869a07b375dc3148de16865de44dec8398672977e050a072e
Status: Downloaded newer image for ubuntu:18.04
1fcf9b3dc841ff2b3c5332bddb13a89a7bd35359944ff3f72247130e02cb12dd

看一下本機映像檔

指令:docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 18.04 20bb25d32758 27 hours ago 87.5MB //剛下載的新映像檔
ubuntu latest 20bb25d32758 27 hours ago 87.5MB

運行映像檔

指令:docker run -i -t ubuntu:18.04 /bin/bash

root@b9fa7dc29a09:/# ls //現在是在啟用的容器 下指行指令
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var

離開容器

root@b9fa7dc29a09:/# exit
exit

如果要在背景執行容器 (多一個參數 -d)
指令:docker run -i -t -d ubuntu:18.04 /bin/bash

查詢背景執行的容器

指令:docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
27a3856d965f ubuntu:18.04 “/bin/bash” 6 seconds ago Up 5 seconds gallant_bell

進入背景容器 (docker exec -i -t CONTAINER ID /bin/bash)CONTAINER ID 請輸入容器編號

指令:docker exec -i -t 27a3856d965f /bin/bash

root@27a3856d965f:/# ls //現在是在背景容器中執行指令
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var

停止背景容器(docker stop CONTAINER ID)CONTAINER ID 請輸入容器編號

指令:docker stop 27a3856d965f

啟用背景容器(docker start CONTAINER ID )CONTAINER ID 請輸入容器編號

指令:docker start 27a3856d965f

評等結果
點擊便能為這篇文章進行評等!
[評等總次數: 0,平均評等: 0]
!去下營經續永站本助幫能就下一點輕輕,話的您到助幫有章文的我果如 如果我的文章有幫助到您的話,輕輕點一下就能幫助本站永續經營下去!

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *