Photon OS – 更新指令 tdnf

在 Photon OS 中是採用與 yum 相類似的套件管理程式 tdnf。
# which tdnf
/usr/bin/tdnf

列出比較常用的參數用法:
移除套件
# tdnf erase package
# tdnf remove package
# tdnf remove nano

Removing:
nano                                                                                x86_64                         2.5.2-2.ph1                                                        1.81 M

Total installed size: 1.81 M
Is this ok [y/N]:

安裝套件
# tdnf install package
# tdnf install nano

Installing:
nano                                                                                x86_64                         2.5.2-2.ph1                                                        1.81 M

Total installed size: 1.81 M
Is this ok [y/N]:y

Downloading:
nano                                    737468    100%
Testing transaction
Running transaction

Complete![@more@]檢查可以更新的套件
# tdnf check-update

清除 Cache
# tdnf clean all

尋找套件
# tdnf search package

顯示套件相關資訊
# tdnf info package

更新已安裝的程式
# tdnf distro-sync

更多的用法:
# tdnf
You need to give some command
usage: tdnf [options] COMMAND

options    [-c [config file]]
           [–debugsolver]
           [–rpmverbosity [debug level name]] [-v] [-y] [–assumeno]
           [–version] [–installroot [path]]
           [–nogpgcheck]
           [–releasever RELEASEVER] [–setopt SETOPTS]
           [–refresh] [-4] [-6] [-h]
List of Main Commands

check-local               Checks local rpm folder for problems
check-update              Check for available package upgrades
clean                     Remove cached data
distro-sync               Synchronize installed packages to the latest available versions
downgrade                 downgrade a package
erase                     Remove a package or packages from your system
help                      Display a helpful usage message
info                      Display details about a package or group of packages
install                   Install a package or packages on your system
list                      List a package or groups of packages
makecache                 Generate the metadata cache
provides                  Find what package provides the given value
remove                    Remove a package or packages from your system
reinstall                 reinstall a package
repolist                  Display the configured software repositories
search                    Search package details for the given string
updateinfo                Display advisories about packages
upgrade                   Upgrade a package or packages on your system
upgrade-to                Upgrade a package on your system to the specified version

Docker – Image 管理

1. 搜尋
[root@docker ~]# docker search b2d
INDEX       NAME                                       DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/matthewlmcclure/javahelloworld   See https://github.com/matthewlmcclure/to-…   0                    [OK]
docker.io   docker.io/ols3/ob2d                        For OB2D Linux container.                       0
docker.io   docker.io/smothiki/qemu-b2d                                                                0
docker.io   docker.io/smothiki/ubuntu-b2d                                                              0

2. 下載
[root@docker ~]# docker pull docker.io/ols3/ob2d
Using default tag: latest
Trying to pull repository docker.io/ols3/ob2d …
latest: Pulling from docker.io/ols3/ob2d

0cb4bcf975cb: Pull complete
14cb4b14bf3d: Pull complete
467076336f48: Pull complete
38b2f86c4e61: Pull complete
Digest: sha256:89c5fbe1533f43f5bf5abc0a26f5fefb898bd5c0525d2c5ccf8df44da668f1db

[@more@]3. 已下載安裝的 Image
# docker images
REPOSITORY                 TAG                 IMAGE ID            CREATED             SIZE
docker.io/base/archlinux   latest              ef9803580a16        17 hours ago        563.4 MB
docker.io/ols3/ob2d        latest              a8ad9770a5b1        2 years ago         371.3 MB

4. 在 Container 執行命令
[root@docker ~]# docker run docker.io/ols3/ob2d apt-get update
Get:1 http://ftp.tw.debian.org wheezy Release.gpg [2373 B]
Get:2 http://ftp.tw.debian.org wheezy Release [191 kB]
Get:3 http://ftp.tw.debian.org wheezy/main amd64 Packages [5839 kB]
Get:4 http://ftp.tw.debian.org wheezy/contrib amd64 Packages [42.0 kB]
Get:5 http://ftp.tw.debian.org wheezy/non-free amd64 Packages [80.8 kB]
Get:6 http://ftp.tw.debian.org wheezy/contrib Translation-en [34.8 kB]
Get:7 http://ftp.tw.debian.org wheezy/main Translation-en [3846 kB]
Get:8 http://deb.ols3.net wheezy Release.gpg [490 B]
Get:9 http://deb.ols3.net wheezy Release [1639 B]
Hit http://ftp.tw.debian.org wheezy/main Translation-zh
Hit http://ftp.tw.debian.org wheezy/main Translation-zh_TW
Get:10 http://deb.ols3.net wheezy/main amd64 Packages [6412 B]
Get:11 http://ftp.tw.debian.org wheezy/non-free Translation-en [66.1 kB]
Ign http://deb.ols3.net wheezy/main Translation-en
Ign http://deb.ols3.net wheezy/main Translation-zh
Ign http://deb.ols3.net wheezy/main Translation-zh_TW
Fetched 10.1 MB in 3s (2623 kB/s)
Reading package lists…
W: There is no public key available for the following key IDs:
7638D0442B90D010

5. 查詢目前使用到 Container
[root@docker ~]# docker ps -a
CONTAINER ID        IMAGE                      COMMAND                  CREATED              STATUS                          PORTS               NAMES
633d01b8003d        docker.io/ols3/ob2d        “cat /etc/debian-vers”   44 seconds ago       Exited (1) 43 seconds ago                           drunk_spence
d197ab903e0f        docker.io/ols3/ob2d        “apt-get update”         About a minute ago   Exited (0) About a minute ago                       pensive_chandrasekhar
a3ae68c6ee14        docker.io/base/archlinux   “/bin/bash”              About an hour ago    Exited (0) 57 minutes ago                           agitated_nobel
dfa510f8be80        docker.io/base/archlinux   “uname -a”               About an hour ago    Exited (0) About an hour ago                        nauseous_nobel
34e3b68242ea        docker.io/base/archlinux   “cat /etc/arch-releas”   About an hour ago    Exited (0) About an hour ago                        gigantic_albattani
1a8382dd773c        docker.io/base/archlinux   “ls -l”                  About an hour ago    Exited (0) About an hour ago                        stupefied_bassi

只列出 的 Container ID
[root@docker ~]# docker ps -a -q
633d01b8003d
d197ab903e0f
a3ae68c6ee14
dfa510f8be80
34e3b68242ea
1a8382dd773c

6. 停止所有的 Container
[root@docker ~]# docker stop $(docker ps -a -q)
633d01b8003d
d197ab903e0f
a3ae68c6ee14
dfa510f8be80
34e3b68242ea
1a8382dd773
停止某一 Image 的 Container
[root@docker ~]# docker stop $(docker ps -a | grep ob2d | awk ‘{print $1}’)

7. 刪除某一 Image 的 Container
[root@docker ~]# docker ps -a | grep ob2d
633d01b8003d        docker.io/ols3/ob2d        “cat /etc/debian-vers”   5 minutes ago       Exited (1) 5 minutes ago                           drunk_spence
d197ab903e0f        docker.io/ols3/ob2d        “apt-get update”         6 minutes ago       Exited (0) 6 minutes ago                           pensive_chandrasekhar
[root@docker ~]# docker rm $(docker ps -a | grep ob2d | awk ‘{print $1}’)
633d01b8003d
d197ab903e0f

8. 刪除某一 Image
[root@docker ~]# docker images | grep ob2d | awk ‘{print $3}’
a8ad9770a5b1
[root@docker ~]# docker rmi $(docker images | grep ob2d | awk ‘{print $3}’)
Untagged: docker.io/ols3/ob2d:latest
Untagged: docker.io/ols3/ob2d@sha256:89c5fbe1533f43f5bf5abc0a26f5fefb898bd5c0525d2c5ccf8df44da668f1db
Deleted: sha256:a8ad9770a5b11e1a4181bd6cab005e12a0e1f9660eab339e902f7d03a25760f8
Deleted: sha256:0933d45fbc5628cc5e627f47b336c06c6725c6f209c82c1ed42b3722aeaa9333
Deleted: sha256:50dc4ad8d2f88a20662290c1b3eb6b65c370a256aad2a96bbb599f19dcb253f2
Deleted: sha256:53d3351c24f8839b83820b2a0e84c46387520269cce1f74f9ed7706629c07238
Deleted: sha256:8e7a2c95af43ed93123e6a2efe65b73bece3c33775f49dab3a628c1126652931

翰林行動大師

為了節能及環保,翰林推出了行動大師,利用一下時間,將學校用到的科目的 ISO 檔先行下載下來,搭配虛擬光碟軟體掛載,方便學校的老師使用。

[@more@]
放在電子書目錄之下

翰林

科目

ISO 檔

在 ISO 檔上按滑鼠右鍵,選擇 掛載

掛載之後的光碟

可以直接使用光碟,或安裝到電腦硬碟

Docker – 解決刪除 image 時出現的錯誤訊息

在刪除 image 時有時候會無法刪除
# docker rmi docker.io/egypcio/freebsd
Error response from daemon: conflict: unable to remove repository reference “docker.io/egypcio/freebsd” (must force) – container 498289b4fbba is using its referenced image 8f539b0870b1

主要的原因是有 container 使用到這一個 image[@more@]解決方式:
刪除 container,可能不只有一個,要全部刪除

刪除 container
# docker rm 2c5e8062fd62
2c5e8062fd62

無法刪除
# docker rmi docker.io/egypcio/freebsd:latest
Error response from daemon: conflict: unable to remove repository reference “docker.io/egypcio/freebsd:latest” (must force) – container 4d4daece60ec is using its referenced image 8f539b0870b1

刪除一個 container
# docker rm 4d4daece60ec
4d4daece60ec

還是無法刪除
# docker rmi docker.io/egypcio/freebsd:latest
Error response from daemon: conflict: unable to remove repository reference “docker.io/egypcio/freebsd:latest” (must force) – container 498289b4fbba is using its referenced image 8f539b0870b1

再刪除一個 container
# docker rm 498289b4fbba
498289b4fbba

終於可以刪掉了!
# docker rmi docker.io/egypcio/freebsd:latest
Untagged: docker.io/egypcio/freebsd:latest
Untagged: docker.io/egypcio/freebsd@sha256:02f6c33382982db829ba63a52ed2467145c290f71f83ae5d8b304c274f809bbd
Deleted: sha256:8f539b0870b1ec6c1552172da492201166440a6f6199a0cd9208820cd377d03a
Deleted: sha256:c92b5d0f8475d3bb10df0bc5e8092da839777747e3653f3cf1cb63b33f17a3ff
Deleted: sha256:474999c372aa6b14e7b8e2afdcab83e2f89b783b243f87d2bbfa9b1a7346962b
Deleted: sha256:7800f80a93336d416612f372faa5f69eb67b353ce6ae9535fa0848f8784c74b1
Deleted: sha256:170b376f64fb30995c140276be3d71dfb256b308d86183ca3b22aa93a79ad548
Deleted: sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef

在 CentOS 7.x 上建立 docker 環境

1. 安裝 docker
# yum install docker

2. 開機啟動及啟動 docker 服務
# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
# systemctl start docker.service

3. 查看 docker 版本資訊
# docker -v
Docker version 1.12.6, build 96d83a5/1.12.6

# docker version
Client:
 Version:         1.12.6
 API version:     1.24
 Package version: docker-common-1.12.6-11.el7.centos.x86_64
 Go version:      go1.7.4
 Git commit:      96d83a5/1.12.6
 Built:           Tue Mar  7 09:23:34 2017
 OS/Arch:         linux/amd64

Server:
 Version:         1.12.6
 API version:     1.24
 Package version: docker-common-1.12.6-11.el7.centos.x86_64
 Go version:      go1.7.4
 Git commit:      96d83a5/1.12.6
 Built:           Tue Mar  7 09:23:34 2017
 OS/Arch:         linux/amd64[@more@]
4. 搜尋 FreeBSD & Arch Linux 映像檔
# docker search freebsd
INDEX       NAME                                           DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/lexaguskov/freebsd                   FreeBSD operating system                        9
docker.io   docker.io/auchida/freebsd                      FreeBSD docker image from distribution arc…   4                    [OK]
docker.io   docker.io/egypcio/freebsd                      FreeBSD Containers (12.0, 11.0, 10.x, or 9.3)   4
docker.io   docker.io/kazuyoshi/freebsd-minimal                                                            4
docker.io   docker.io/amontalban/freebsd                   FreeBSD Images for Docker.                      3                    [OK]
docker.io   docker.io/roobixx/docker-dg                    DansGuardian is an award winning Open Sour…   2                    [OK]
docker.io   docker.io/vongrippen/freebsd                   FreeBSD with pkg installed                      1
docker.io   docker.io/alexcrichton/port-prebuilt-freebsd                                                   0
docker.io   docker.io/bbabich/docker-mfi-controller        UBNT mfi-controller FreeBSD w/ZFS Docker S…   0                    [OK]
docker.io   docker.io/catskillmts/freebsdminimal                                                           0
docker.io   docker.io/danielstaleiny/freebsd                                                               0
docker.io   docker.io/jamesandariese/go-freebsd-386                                                        0                    [OK]
docker.io   docker.io/jamesandariese/go-freebsd-amd64                                                      0                    [OK]
docker.io   docker.io/jamesandariese/go-freebsd-arm                                                        0                    [OK]
docker.io   docker.io/japaric/i686-unknown-freebsd                                                         0
docker.io   docker.io/japaric/x86_64-unknown-freebsd                                                       0
docker.io   docker.io/mattboll/freebsd                     testing freebsd images                          0
docker.io   docker.io/ptomulik/freebsd                     FreeBSD base images                             0
docker.io   docker.io/ptomulik/freebsd-ports               FreeBSD images with ports preinstalled          0
docker.io   docker.io/qlkao/freebsd                                                                        0
docker.io   docker.io/rustci/rustci-x86_64-freebsd                                                         0
docker.io   docker.io/siffland/freebsd-memcached           FreeBSD memcached docker                        0
docker.io   docker.io/supsup5642/freebsd_ubuntu                                                            0
docker.io   docker.io/tunisiano187/docker-freebsd          FreeBSD template automated                      0                    [OK]

# docker search archlinux
INDEX       NAME                                     DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
docker.io   docker.io/base/archlinux                 Basic ArchLinux installation                    212                  [OK]
docker.io   docker.io/finalduty/archlinux            A minimal Arch Linux base image for Docker…   17                   [OK]
docker.io   docker.io/logankoester/archlinux         A fully updated Arch Linux base image buil…   8                    [OK]
docker.io   docker.io/derjudge/archlinux                                                             7                    [OK]
docker.io   docker.io/greyltc/archlinux              Baseline Arch Linux image with an open, tr…   5                    [OK]
docker.io   docker.io/archlinuxjp/archlinux          The latest Arch Linux Docker image              4                    [OK]
docker.io   docker.io/thedcg/tl-archlinux            tl-archlinux                                    2                    [OK]
docker.io   docker.io/archlinuxjp/archlinux-min      The mini Arch Linux Docker image                1                    [OK]
docker.io   docker.io/archlinuxjp/archlinux-yaourt   + Yaourt to base image                          1                    [OK]
docker.io   docker.io/finalduty/archlinux-base       Personalised ArchLinux image                    1                    [OK]
docker.io   docker.io/obedmr/archlinux               ArchLinux Base Image                            1                    [OK]
docker.io   docker.io/opamp/archlinux                my archlinux base image with yaourt             1                    [OK]
docker.io   docker.io/ac1965/archlinux               A minimum environment of ArchLinux with Do…   0                    [OK]
docker.io   docker.io/admiringworm/archlinux         Archlinux base image based on pritunl/arch…   0                    [OK]
docker.io   docker.io/alekzonder/archlinux           fresh archlinux image every day                 0                    [OK]
docker.io   docker.io/alekzonder/archlinux-yaourt    fresh archlinux with yaourt tool for build…   0                    [OK]
docker.io   docker.io/archlinuxjp/archlinux-test     test image                                      0                    [OK]
docker.io   docker.io/colajam93/archlinux            Arch Linux Dockerfile for my testing / pac…   0                    [OK]
docker.io   docker.io/desiato/build-archlinux        archlinux-bootstrap builder                     0                    [OK]
docker.io   docker.io/freenas/archlinux              Simple Arch Linux interactive container         0                    [OK]
docker.io   docker.io/jackus/archlinux               Archlinux updated on build                      0                    [OK]
docker.io   docker.io/masm/archlinux                 A fully updated Arch Linux base image buil…   0                    [OK]
docker.io   docker.io/oblique/archlinux-pacaur       ArchLinux + pacaur                              0                    [OK]
docker.io   docker.io/smartentry/archlinux           archlinux with smartentry                       0                    [OK]
docker.io   docker.io/soem/archlinux                 Archlinux Minimal installation                  0                    [OK]

5. 下載
# docker pull docker.io/egypcio/freebsd
Using default tag: latest
Trying to pull repository docker.io/egypcio/freebsd …
latest: Pulling from docker.io/egypcio/freebsd

a3ed95caeb02: Pull complete
14a15dd57b8b: Pull complete
Digest: sha256:02f6c33382982db829ba63a52ed2467145c290f71f83ae5d8b304c274f809bbd

# docker pull docker.io/base/archlinux
Using default tag: latest
Trying to pull repository docker.io/base/archlinux …
latest: Pulling from docker.io/base/archlinux
ae06c652a19e: Pull complete
dd332190f0f1: Pull complete
3e401a3e6fe9: Pull complete
Digest: sha256:fe0829b6d78fd834a5300a84c559eab9cfe2056fe3c54b5418984ea374075506

6. 已下載安裝的映像檔
# docker images
REPOSITORY                  TAG                 IMAGE ID            CREATED             SIZE
docker.io/base/archlinux    latest              ef9803580a16        16 hours ago        563.4 MB
docker.io/egypcio/freebsd   latest              8f539b0870b1        6 months ago        331.3 MB

7. 在容器中執行命令
# docker run docker.io/base/archlinux ls -l
total 4
lrwxrwxrwx   1 root root    7 Dec  5 23:43 bin -> usr/bin
drwxr-xr-x   2 root root    6 Dec  5 23:43 boot
drwxr-xr-x   5 root root  360 Apr  1 03:44 dev
drwxr-xr-x  27 root root 4096 Apr  1 03:44 etc
drwxr-xr-x   2 root root    6 Dec  5 23:43 home
lrwxrwxrwx   1 root root    7 Dec  5 23:43 lib -> usr/lib
lrwxrwxrwx   1 root root    7 Dec  5 23:43 lib64 -> usr/lib
drwxr-xr-x   2 root root    6 Dec  5 23:43 mnt
drwxr-xr-x   2 root root    6 Dec  5 23:43 opt
dr-xr-xr-x 187 root root    0 Apr  1 03:44 proc
drwxr-x—   3 root root   20 Mar 31 11:21 root
drwxr-xr-x   4 root root   33 Apr  1 03:44 run
lrwxrwxrwx   1 root root    7 Dec  5 23:43 sbin -> usr/bin
drwxr-xr-x   4 root root   29 Mar 31 11:21 srv
dr-xr-xr-x  13 root root    0 Apr  1 03:15 sys
drwxrwxrwt   2 root root    6 Mar 31 11:21 tmp
drwxr-xr-x   8 root root  105 Mar 31 11:21 usr
drwxr-xr-x  12 root root  160 Mar 31 11:22 var

當使用 docker run 來建立容器時,Docker 在後台會進行下列的工作:

  • 檢查本地端是否存在指定的映像檔,如果不存在就從公有的倉庫下載
  • 利用映像檔建立並啟動一個容器
  • 分配一個檔案系統,並在唯讀的映像檔層外面掛載一層可讀寫層
  • 從 Host 主機設定的網路橋接介面中橋接一個虛擬埠到容器之中
  • 從位址 Pool 中設定一個 IP 位址給容器
  • 執行使用者指定的應用程式
  • 執行完畢後容器終止

8. 進入 Arch Linux 容器
-t 讓 Docker 分配一個虛擬終端機(pseudo-tty) 並綁定到容器的標準輸入上
-i 讓容器的標準輸入保持打開
[root@docker ~]# docker run -t -i docker.io/base/archlinux /bin/bash
[root@a3ae68c6ee14 /]# pacman -Syy
:: Synchronizing package databases…
 core                     124.3 KiB   302K/s 00:00 [######################] 100%
 extra                   1678.7 KiB  2.65M/s 00:01 [######################] 100%
 community                  3.8 MiB  4.42M/s 00:01 [######################] 100%

[root@a3ae68c6ee14 /]# pacman -S vim
resolving dependencies…
looking for conflicting packages…

Packages (3) gpm-1.20.7-7  vim-runtime-8.0.0427-1  vim-8.0.0427-1

Total Download Size:    6.53 MiB
Total Installed Size:  29.65 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages…
 gpm-1.20.7-7-x86_64      127.5 KiB   310K/s 00:00 [######################] 100%
 vim-runtime-8.0.042…     5.2 MiB  4.48M/s 00:01 [######################] 100%
 vim-8.0.0427-1-x86_64   1247.8 KiB  5.25M/s 00:00 [######################] 100%
(3/3) checking keys in keyring                     [######################] 100%
(3/3) checking package integrity                   [######################] 100%
(3/3) loading package files                        [######################] 100%
(3/3) checking for file conflicts                  [######################] 100%
(3/3) checking available disk space                [######################] 100%
:: Processing package changes…
(1/3) installing vim-runtime                       [######################] 100%
(2/3) installing gpm                               [######################] 100%
(3/3) installing vim                               [######################] 100%
Optional dependencies for vim
    python2: Python 2 language support
    python: Python 3 language support
    ruby: Ruby language support
    lua: Lua language support
    perl: Perl language support [installed]
    tcl: Tcl language support
:: Running post-transaction hooks…
(1/1) Arming ConditionNeedsUpdate…

9. 退出 exit 或 Ctrl+D
[root@a3ae68c6ee14 /]# exit
exit
[root@docker ~]#

10. 二者使用的核心是相同的
# docker run docker.io/base/archlinux uname -a
Linux dfa510f8be80 3.10.0-514.10.2.el7.x86_64 #1 SMP Fri Mar 3 00:04:05 UTC 2017 x86_64 GNU/Linux
# uname -a
Linux docker.test.ilc.edu.tw 3.10.0-514.10.2.el7.x86_64 #1 SMP Fri Mar 3 00:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

11.儲存映像檔到本地端
# docker save -o archlinux.tar docker.io/base/archlinux
# ls -l *.tar
-rw——-. 1 root root 584920064  4月  1 12:12 archlinux.tar

12. 載入本地端映像檔
# docker load –input archlinux.tar

# docker load < archlinux.tar

13. 移除映像檔
# docker rmi docker.io/egypcio/freebsd:latest
Untagged: docker.io/egypcio/freebsd:latest
Untagged: docker.io/egypcio/freebsd@sha256:02f6c33382982db829ba63a52ed2467145c290f71f83ae5d8b304c274f809bbd
Deleted: sha256:8f539b0870b1ec6c1552172da492201166440a6f6199a0cd9208820cd377d03a
Deleted: sha256:c92b5d0f8475d3bb10df0bc5e8092da839777747e3653f3cf1cb63b33f17a3ff
Deleted: sha256:474999c372aa6b14e7b8e2afdcab83e2f89b783b243f87d2bbfa9b1a7346962b
Deleted: sha256:7800f80a93336d416612f372faa5f69eb67b353ce6ae9535fa0848f8784c74b1
Deleted: sha256:170b376f64fb30995c140276be3d71dfb256b308d86183ca3b22aa93a79ad548
Deleted: sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef

# docker run -i -d -t docker.io/base/archlinux /bin/bash2332c0ada7596a74cafa5ea4fca41f37259c9cfa6a762a207ec7b313a743e37a

# docker ps
CONTAINER ID        IMAGE                      COMMAND             CREATED              STATUS              PORTS               NAMES
2332c0ada759        docker.io/base/archlinux   “/bin/bash”         About a minute ago   Up About a minute                       agitated_yalow

# docker attach agitated_yalow
[root@2332c0ada759 /]#

VMware ESXi – 利用 Photon OS 虛擬機建立 Docker 環境

參考網站:
用ESXi建Photon OS虛擬機 打造超輕量Docker環境 – 專題報導 – 網管人NetAdmin
Basic Commands for VMware Photon and Docker | Virten.net

1. 執行內建的 Nginx 網站
連上網路下載
-d 以 Daemonized 形式執行
# docker run -d -p 80:80 vmwarecna/nginx
Unable to find image ‘vmwarecna/nginx:latest’ locally
latest: Pulling from vmwarecna/nginx
a3ed95caeb02: Pull complete
b6f2388a20dd: Pull complete
a305e4b888ce: Pull complete
80596a504ef3: Pull complete
99c028eff2a4: Pull complete
a1cee46bc434: Pull complete
9bd9868012b9: Pull complete
6fa7100a2613: Pull complete
Digest: sha256:f73bbae0f31823c06478b1fa5efb4957bc25239802fd5ea94e4442c0a6090d23
Status: Downloaded newer image for vmwarecna/nginx:latest
085923c591c6b63b477d3267e4f42945a02ea8ebf828e030740b4c299f0e6d57[@more@]執行之後,會新增 docker0 網路介面
# ifconfig docker0
docker0   Link encap:Ethernet  HWaddr 02:42:fa:50:60:86
          inet addr:172.17.0.1  Bcast:0.0.0.0  Mask:255.255.0.0
          inet6 addr: fe80::42:faff:fe50:6086/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:69 errors:0 dropped:0 overruns:0 frame:0
          TX packets:90 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:101690 (101.6 KB)  TX bytes:7392 (7.3 KB)

防火牆部分也會新增規則
# iptables -L DOCKER -n
Chain DOCKER (1 references)
target     prot opt source               destination
ACCEPT     tcp  —  0.0.0.0/0            172.17.0.2           tcp dpt:80

2. 開啟瀏覽器,輸入 Photon OS IP

3. Docker 版本
# docker version
Client:
 Version:      1.11.0
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   4dc5990
 Built:        Wed Apr 13 19:36:04 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.11.0
 API version:  1.23
 Go version:   go1.5.4
 Git commit:   4dc5990
 Built:        Wed Apr 13 19:36:04 2016
 OS/Arch:      linux/amd64

#Download a Docker container (https://registry.hub.docker.com/)
docker pull vmwarecna/nginx

#Display local stored Docker images
docker images

#Start Docker Container
# -d       – Run the container in the background
# -p 80:80 – Publish the container’s port to the host
docker run -d -p 80:80 vmwarecna/nginx

#List running Docker Containers
docker ps

#Display the public-facing port that is NAT-ed to the container
#(Container ID from docker ps command)
docker port 5f6b0e03c6de

#Stop Docker Container
docker stop 5f6b0e03c6de

#Automatically start Docker containers at boot time
#To start a container at boot time the restart policy parameter is used. 
docker run –restart=always -d -p 80:80 vmwarecna/nginx

Adobe Flash Player 26.0.0.151


檢查安裝版本:https://www.adobe.com/tw/software/flash/about/ 
                               https://get.adobe.com/tw/flashplayer/
[@more@]

Windows 7 平台 
Internet Explorer: 
http://fpdownload.adobe.com/get/flashplayer/pdc/26.0.0.151/install_flash_player_ax.exe 
Windows 8 / 8.1 / 10 / Server 2012 R2 / Server 2016 要從 Windows Update 更新 

All Other Browsers(Firefox…): 
http://fpdownload.adobe.com/get/flashplayer/pdc/26.0.0.151/install_flash_player.exe 

Google Chrome(Opera) 
http://fpdownload.adobe.com/get/flashplayer/pdc/26.0.0.151/install_flash_player_ppapi.exe 

Mac 平台: 
http://fpdownload.adobe.com/get/flashplayer/pdc/26.0.0.151/install_flash_player_osx.dmg

VMware ESXi – 安裝 Photon OS 虛擬機器

Photon OS 官方網站:https://vmware.github.io/photon/

1. 下載 Photon OS,這裡下載的是 Full ISO

[@more@]2. 先把 ISO 檔上傳到 ESXi Server 資料存放區

3. 建立虛擬機器

4. 進行安裝
    選擇 Install   

  
    選擇 Accept

    選擇 Yes

    選擇安裝的方式,詳細可以參考 用ESXi建Photon OS虛擬機 打造超輕量Docker環境 – 專題報導 – 網管人NetAdmin

    設定主機名稱

    設定 root 密碼

    確認 root 密碼

    按任意鍵重新開機

5. 開機畫面

    登入畫面

    登入完成

6. 進行設定
SSH Server 設定
# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.$(date +%F)
# sed -i ‘s/PermitRootLogin no/PermitRootLogin yes/’ /etc/ssh/sshd_config
# systemctl restart sshd.service

7. 設定網路
# sed -i ‘s/DHCP=yes/DHCP=no/’ /etc/systemd/network/10-dhcp-en.network

# networkctl | grep configured
  2 eth0             ether              routable    configured

設定網路
# vim /etc/systemd/network/10-static-en.network
[Match]
Name=eth0

[Network]
Address=192.168.1.134/24
Gateway=192.168.1.2
Address=2001:288:a229:1::134/64
Gateway=2001:288:a229:1::ffff
DNS=8.8.8.8
DNS=168.95.1.1

Domains=photon.local

# chmod 644 /etc/systemd/network/10-static-en.network

重新啟動網路
# systemctl restart systemd-networkd.service

測試 DNS 查詢是否正常
# ping -c 3 www.ilc.edu.tw
PING www.ilc.edu.tw (140.111.66.96) 56(84) bytes of data.
64 bytes from server96.ilc.edu.tw (140.111.66.96): icmp_seq=1 ttl=126 time=1.06 ms
64 bytes from server96.ilc.edu.tw (140.111.66.96): icmp_seq=2 ttl=126 time=1.16 ms
64 bytes from server96.ilc.edu.tw (140.111.66.96): icmp_seq=3 ttl=126 time=0.983 ms

# ping6 -c 3 www.ilc.edu.tw
PING www.ilc.edu.tw(2001:288:a201::66:96) 56 data bytes
64 bytes from 2001:288:a201::66:96: icmp_seq=1 ttl=126 time=1.67 ms
64 bytes from 2001:288:a201::66:96: icmp_seq=2 ttl=126 time=1.68 ms
64 bytes from 2001:288:a201::66:96: icmp_seq=3 ttl=126 time=1.53 ms

8. 設定防火牆
# vim /etc/systemd/scripts/iptables

iptables -A INPUT -p tcp –dport 22 -j ACCEPT
修改成
iptables -A INPUT -p tcp -s 192.168.1.0/24 –dport 22 -j ACCEPT

# systemctl restart iptables.service
# iptables -L -n
Chain INPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  —  0.0.0.0/0            0.0.0.0/0
ACCEPT     all  —  0.0.0.0/0            0.0.0.0/0            ctstate RELATED,ESTABLISHED
ACCEPT     tcp  —  192.168.1.0/24      0.0.0.0/0            tcp dpt:22

Chain FORWARD (policy DROP)
target     prot opt source               destination

Chain OUTPUT (policy DROP)
target     prot opt source               destination
ACCEPT     all  —  0.0.0.0/0            0.0.0.0/0

9. 設定時區
# rm -rf /etc/localtime
# ln -s /usr/share/zoneinfo/Asia/Taipei /etc/localtime
# date
Fri Mar 31 17:57:10 CST 2017

10. 設定開機時啟動 docker
# systemctl enable docker.service
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
# systemctl start docker.service