當前位置:
首頁 > 知識 > 最新Docker的安裝與使用以及常見問題 Linux Windows

最新Docker的安裝與使用以及常見問題 Linux Windows

安裝

  • 官方文檔

Linux下安裝(CentOS 7.x)

  • yum install -y docker
  • 查看版本 docker --version

Windows下安裝

  • 官方說明
  • 安裝條件
  • 方式一:
  • 截至2018年9月8日 官方要求:64位的Windows 10 Pro專業版,Enterprise企業版或Education教育版(1607周年更新,Build 14393或更高版本)Docker for Windows Installer.exe(下載地址)
  • 另外由於Windows版安裝了Hyper-V 需開啟硬體虛擬化百度教程
  • 方式二:
  • 不滿足上述條件並且在此之前的windows版本可下載 Docker Toolbox(下載地址)

不滿足方式一的話建議就別在windows上玩,免得麻煩而且windows在上學習沒啥用,當然若果你執迷不悟那就升級系統吧:Win10家庭版升級至Win10專業版,控制面板-系統和安全-系統-更換產品密鑰 「VK7JG-NPHTM-C97JM-9MPGT-3V66T」

  • 注意事項
  • 安裝Docker for Windows後會提示安裝Hyper-V虛擬機,安裝完成後需重啟電腦才可使用
  • 安裝完成重啟後自動啟動docker成功後,右鍵右下角docker圖標-settings進入設置如圖

最新Docker的安裝與使用以及常見問題 Linux Windows

  • 選擇共享盤符,勾選後需輸入你電腦PC用戶開機登錄密碼

最新Docker的安裝與使用以及常見問題 Linux Windows

  • 若偶爾docker for windows啟動失敗,屬抽風正常現象,請重新啟動docker或重啟電腦,仍無法啟動請考慮嘗試重置Docker(謹慎!將清空已安裝好的所有鏡像)

最新Docker的安裝與使用以及常見問題 Linux Windows

  • Toolbox版本安裝後啟動需下載鏡像,請保持網路通暢,等待下載完畢後將啟動成功

mac系統安裝見官方文檔或百度

基本啟用

  • 啟動docker service docker start
  • 重啟 service docker restart
  • 關閉 service docker stop

常用命令

  • 學會常用help命令或查看 官方文檔說明

$ docker --help
Usage: docker COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default "/root/.docker")
-D, --debug Enable debug mode
--help Print usage
-H, --host list Daemon socket(s) to connect to (default [])
-l, --log-level string Set the logging level ("debug", "info", "warn", "error", "fatal") (default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/root/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/root/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Management Commands:
container Manage containers
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
volume Manage volumes
Commands:
attach Attach to a running container
build Build an image from a Dockerfile
commit Create a new image from a container"s changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes on a container"s filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container"s filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes
Run "docker COMMAND --help" for more information on a command.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76

基本命令

倉庫相關操作

docker pull #從遠程倉庫拉取鏡像到本地
docker push #推送本地鏡像到遠程倉庫
docker search #在倉庫搜索鏡像
docker login #登錄到官方倉庫Docker Hub
docker logout #退出登錄
1
2
3
4
5

鏡像相關操作

docker build #從Dockerfile構建鏡像
docker pull #同上
docker push #同上
docker history #顯示鏡像的歷史信息
docker images #列出鏡像
docker rmi #刪除鏡像
docker tag #給鏡像打上tag標籤
docker run #創建容器並啟動容器
docker create #創建容器
docker commit #將修改後的容器生成鏡像
docker load #從壓縮包中載入鏡像
docker import #從歸檔文件中創建鏡像
docker save #將鏡像保存到壓縮文件
1
2
3
4
5
6
7
8
9
10
11
12
13

容器相關操作

docker attach #依附到一個正在運行的容器中
docker exec #進到正在運行的容器中執行命令
docker cp #在容器和本地系統間複製文件
docker update #將一個容器內所有的進程從暫停狀態中恢復
docker ps #列出主機中的容器
docker port #查找一個nat到私有網口的公共口
docker top #查看一個容器中正在運行的進程信息
docker logs #查看日誌文件
docker diff #檢查容器內文件系統的修改
docker status #輸出容器的資源使用統計信息
docker wait #阻塞直到容器終止
docker start #啟動已創建的容器
docker pause #暫停運行中的容器
docker unpause #使暫停的容器恢復運行
docker stop #停止容器運行
docker rename #容器改名
docker restart #容器重啟
docker kill #關閉運行中的容器
docker rm #刪除容器
docker export #導出容器內容為tar包
docker run #同上
docker create #同上
docker commit #同上
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

其他基本命令

docker events #從服務端獲取實時的事件
docker info #查看系統相關信息
docker inspect #顯示Docker對象的具體配置信息,包括容器,鏡像,網路等
docker version #輸出Docker的版本信息
1
2
3
4

管理命令

docker container #容器管理
docker image #鏡像管理
docker network #網路管理
docker node #節點管理
docker plugin #插件管理
docker secret #管理敏感數據及普通服務配置項
docker service #服務管理
docker stack #棧管理
docker swarm #集群管理
docker system #管理系統信息
docker volume #卷管理
1
2
3
4
5
6
7
8
9
10
11

一些命令圖幫助大家記憶理解

最新Docker的安裝與使用以及常見問題 Linux Windows

最新Docker的安裝與使用以及常見問題 Linux Windows

喜歡這篇文章嗎?立刻分享出去讓更多人知道吧!

本站內容充實豐富,博大精深,小編精選每日熱門資訊,隨時更新,點擊「搶先收到最新資訊」瀏覽吧!


請您繼續閱讀更多來自 程序員小新人學習 的精彩文章:

並發編程之AQS(AbstractQueuedSynchronizer)
eclipse如何導出WAR包

TAG:程序員小新人學習 |