1. 程式人生 > 其它 >k8s ingress配置網站https訪問

k8s ingress配置網站https訪問

一、建立容器

1.新建容器

D:\docker_test>docker create -it ubuntu:18.04
27a54582fc805198ef33509a0be1afc75518dc20b2adc8ece019eef94c9391e1

2.啟動容器

D:\docker_test>docker start 27a54582fc80
27a54582fc80

3.新建並啟動容器

D:\docker_test>docker run ubuntu:18.04 /bin/echo "hello world"
hello world

啟動一個bash終端,允許使用者進行互動:

D:\docker_test>docker run -it ubuntu:18.04
/bin/bash root@4bce07ec5055:/#

-t:分配一個偽終端並繫結在容器的標準輸入上

-i:讓容器的標準輸入開啟

退出容器

root@4bce07ec5055:/# exit
exit

4.守護程序執行

D:\docker_test>docker run -d ubuntu:18.04  /bin/sh -c "while true; do echo hello world; sleep 1; done"
5de1d8da353b84babeeea7626b82ab541956ed0abb1e6ac5cedc6c043f76d453

5.檢視容器輸出

D:\docker_test>docker logs 5de1d8da353b
hello world
hello world

二、停止容器

1.暫停容器

D:\docker_test>docker pause 27a54582fc80
27a54582fc80

2.停止容器

D:\docker_test>docker stop 27a54582fc80

3.重啟容器

D:\docker_test>docker restart 27a54582fc80
27a54582fc80

三、進入容器

在使用-d引數時,容器啟動後會進入後臺,使用者無法看到容器中的資訊,也無法進行操作。這個時候如果需要進入容器進行操作,推薦使用官方的attach或exec命令。

1.attach命令

D:\docker_test>docker attach 27a54582fc80
root@27a54582fc80:
/# exit exit

當退出容器後,容器狀態也停止

D:\docker_test>docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS                   PORTS     NAMES
5de1d8da353b   ubuntu:18.04   "/bin/sh -c 'while t…"   13 minutes ago   Up 13 minutes (Paused)             xenodochial_blackburn

2.exec命令

D:\docker_test>docker exec -it 5de1d8da353b /bin/bash
root@5de1d8da353b:/# exit
exit

D:\docker_test>docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS              PORTS     NAMES
5de1d8da353b   ubuntu:18.04   "/bin/sh -c 'while t…"   19 minutes ago   Up About a minute             xenodochial_blackburn

退出容器,容器狀態不停止

四、刪除容器

D:\docker_test>docker rm 27a54582fc80
27a54582fc80

預設情況下,docker rm命令只刪除已經停止或退出狀態的容器,並不能刪除正在執行的容器

-f:強制停止並刪除正在執行的容器

-l:刪除容器的連線,但保留容器

-v:刪除容器掛載的資料卷

五、匯入和匯出容器

1.匯出容器

D:\docker_test>docker export -o test_for_a41e52d3fb88.tar a41e52d3fb88

-o:指定匯出tar的檔名

2.匯入容器

D:\docker_test>docker import test_for_a41e52d3fb88.tar test/ubuntu:18.041

注意:匯入的容器會變成映象,而不是容器

D:\docker_test>docker images
REPOSITORY    TAG       IMAGE ID       CREATED              SIZE
test/ubuntu   18.041    abd89c228b21   About a minute ago   63.1MB

六、檢視容器

1.檢視容器詳情

D:\docker_test>docker inspect 5de1d8da353b

2.檢視容器內程序

D:\docker_test>docker top 5de1d8da353b
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                2291                2271                0                   13:09               ?                   00:00:01            /bin/sh -c while true; do echo hello world; sleep 1; done
root                3801                2291                0                   13:32               ?                   00:00:00            sleep 1

3.檢視統計資訊

D:\docker_test>D:\docker_test>docker stats

4.其他命令

 1)複製檔案

D:\docker_test>docker cp data 5de1d8da353b:/tmp/

 2)檢視變更

D:\docker_test>docker diff 5de1d8da353b
C /root
A /root/.bash_history

 3)檢視埠對映

D:\docker_test>docker port 4bce07ec5055

 4)更新配置

D:\docker_test>docker update 4bce07ec5055