docker簡單命令
- 執行docker服務:
service docker start
- 顯示docker資訊:
docker info
- 顯示docker版本:
docker version
- 顯示擁有的images:
docker images
- 顯示正在執行的Container:
docker ps
- 顯示所有的Container:
docker ps -a
- 拉取images:
docker pull image-name
- 執行images:
docker run image-name
- 提交新的images:
docker commit container-id
- 幫助:
docker help
- 停止容器:
docker stop nameπ
- 重啟容器:
docker restart name
- 移除容器:
docker rm name
- 搜尋images:
docker search (image-name)
- 檢視映象歷史版本:
docker history (image_name)
- 推送映象:
docker push (image_name)
- 刪除映象:
docker rmi (image_name)
- 檢查映象:
docker inspect (container_name)
- 進入容器:
docker exec -it (container_name) /bin/bash
- 掛載資料卷:
docker run -v $PWD/data:/var/data (container_name)
- 從容器掛載資料卷:
docker create -v PWD/data:/var/data --name (container_name) ubuntu
docker run -it -volume-from (one_container) ubuntu /bin.bash
- MAC進入虛擬機器:
screen /Users/(your username)/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
- 執行Dockerfile
docker build -t (image_name) .(執行上下文)
- Portainert圖形介面管理P
docker volume create portainer_data
docker container run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
- docker批量刪除容器、映象
刪除所有容器:docker rm `docker ps -a -q`
刪除所有映象:docker rmi `docker images -q`
刪除沒有打標籤映象:ocker rmi `docker images -q | awk ‘/^/ { print $3 }’`
- Dockerfile事例:
FROM ubuntu
MAINTAINER zwq
RUN apt-get update
RUN apt-get install -y nginx
COPY index.html /var/www/html
ENTRYPOINT ["/usr/sbin/nginx","-g","daemon off;"]
EXPOSE 80