Docker快速入門
docker概念
DockerConcept.jpg
install docker
- check kernal version > 3.10
uname -r
- install docker
yum install docker
- run docker
systemctl start docker
- check docker version
docker -v
- 開機啟動docker
systemctl enable docker
- 停止docker
systemctl stop docker
docker 常用指令
1.image相關
操作 | 指令 | 說明 |
---|---|---|
search | docker search eg.docker search redis | 搜尋image,也可以上docker hub尋找 |
pull | docker pull imageName:tag | tag是可選參數,默認為latest |
list | docker images | 查看local有哪些image可用 |
delete | docker rmi image-id | 刪除local image |
2.container操作
運行一個image就會產生一個container
- 搜尋tomcat image
docker seacher tomcat
- 從remote拉下image
docker pull tomcat
- 啟動tomcat image,–name給container一個名稱,-d後臺運行
docker run --name mytomcat -d tomcat:latest
- 查看在運行的container
docker ps
- 停止運行的container
docker stop containerId
- 查看所有容器
docker ps -a
- 啟動container
docker start containId
- 刪除一個container
docker rm containerId
- 啟動一個端口映射的tomcat,-p 主機端口:容器內部端口
docker run -d -p 8888:8080 tomcat
- 關閉linux防火牆
service firewalld status
service firewalld stop
- 查看container日誌
docker logs containerName/containId
docker exec containerId command
ex. docker exec -it mytomcat /bin/bash
reference
All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Comment