Featured image of post Docker - 基礎環境安裝

Docker - 基礎環境安裝

Docker起手式

JR最近開始複習Docker使用,早期Docker剛出來的時候JR就搶先學習,不過當時的時空背景,很多服務都還是跑在VMware虛擬機上,公司方面也比較守舊,因此JR只能自己下設的伺服器玩,Docker經過多年的雲端運用驗證,許多公司也陸續由傳統虛擬機的使用方式轉換使用Docker,而現在也有不少協同管理Docker的工具平台,因此JR決定將放下許久的Docker重拾起來,第一步就是安裝Docker。

JR自己使用的環境為Ubuntu Server,以下以此系統為基礎來安裝Docker。

Docker安裝

1
$ sudo apt-get install docker.io -y

查看Docker版本

1
2
$ sudo docker --version
Docker version 20.10.2, build 20.10.2-0ubuntu1~20.04.2

開啟Docker服務

1
2
$ sudo systemctl start docker
$ sudo systemctl enable docker

測試

先來載個image做測試。

1
$ sudo docker pull hello-world

查看images。

1
2
3
$ sudo docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    d1165f221234   3 months ago   13.3kB

執行image。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
Allenen@JR-ubuntu-server:~$ sudo docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

看到以上結果即為成功。

Licensed under CC BY-NC-SA 4.0
Built with Hugo
Theme Stack designed by Jimmy