Docker 基本指令
在Docker啟動一個最小化的ubuntu/ CentOS/ Nginx/ MariaDB 環境 (創造貨櫃主機)
syntax: docker run --rm -it ubuntu
-
--rm Automatically remove the container when it exits
-
-it Instructs Docker to allocate a pseudo-TTY connected to the container’s stdin
(pseudo-TTY = 虛擬終端機/ TTY = teletypes/ stdin = standard in)
-
-d detached: Run container in background and print container ID
查詢IP location
hostname -i
cat /etc/hosts
docker exec [ID] hostname -i
Run a command in a running container
docker exec -it [container_ID] sh
Stop one or more running containers
syntax: docker stop [container_ID]
List containers
syntax: docker ps -a
-a Show all containers (default shows just running)
apt-get 指令
apt-get upgrade
apt-get install all: 安裝全部套件
ifconfig
brctl show
Appendix
參考 Docker docs
參考 Docker —— 從入門到實踐
Docker 基本指令
在Docker啟動一個最小化的ubuntu/ CentOS/ Nginx/ MariaDB 環境 (創造貨櫃主機)
syntax:
docker run --rm -it ubuntu--rmAutomatically remove the container when it exits-itInstructs Docker to allocate a pseudo-TTY connected to the container’s stdin(pseudo-TTY = 虛擬終端機/ TTY = teletypes/ stdin = standard in)
-ddetached: Run container in background and print container ID查詢IP location
hostname -icat /etc/hostsdocker exec [ID] hostname -iRun a command in a running container
docker exec -it [container_ID] shStop one or more running containers
syntax:
docker stop [container_ID]List containers
syntax:
docker ps -a-aShow all containers (default shows just running)apt-get 指令
apt-get upgradeapt-get install all: 安裝全部套件ifconfigbrctl showAppendix
參考 Docker docs
參考 Docker —— 從入門到實踐