Bub*_*nja 14 windows powershell cmd docker
我想知道如何通过命令行(cmd 或 powershell)检查 Docker 是否在 Windows 上运行。
虽然,我发现了几篇文章指出了解决方案,但它们适用于 Linux 环境:
我无法得到 Windows 系统的答案。
小智 13
尝试在 Powershell 或 cmd 上运行这些命令中的任何一个,如果安装了 docker,您应该得到无错误响应:
docker --version
或
docker-compose --version
或
docker ps
atl*_*ine 11
Afford two methods:
docker version
This method works both for cmd & powershell, but if for cmd, you need to use echo %errorlevel% to check the result.
If docker daemon is running, it will be like next:
PS C:\> docker version
Client: Docker Engine - Community
Version: 18.09.2
API version: 1.39
Go version: go1.10.8
Git commit: 6247962
Built: Sun Feb 10 04:12:31 2019
OS/Arch: windows/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.2
API version: 1.39 (minimum version 1.12)
Go version: go1.10.6
Git commit: 6247962
Built: Sun Feb 10 04:13:06 2019
OS/Arch: linux/amd64
Experimental: false
PS C:\> echo $?
True
Run Code Online (Sandbox Code Playgroud)
If docker daemon not running, it will be next:
PS C:\> docker version
Client: Docker Engine - Community
Version: 18.09.2
API version: 1.39
Go version: go1.10.8
Git commit: 6247962
Built: Sun Feb 10 04:12:31 2019
OS/Arch: windows/amd64
Experimental: false
Error response from daemon: An invalid argument was supplied.
PS C:\> echo $?
False
Run Code Online (Sandbox Code Playgroud)Get-Process:
This method just works for powershell.
If docker daemon is running, it will be next:
PS C:\> Get-Process 'com.docker.proxy'
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
205 10 11416 18860 0.13 12620 2 com.docker.proxy
PS C:\> echo $?
True
Run Code Online (Sandbox Code Playgroud)
If docker daemon is not running, it will be next:
PS C:\> Get-Process 'com.docker.proxy'
Get-Process : Cannot find a process with the name "com.docker.proxy". Verify the process name and call the cmdlet
again.
At line:1 char:1
+ Get-Process 'com.docker.proxy'
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (com.docker.proxy:String) [Get-Process], ProcessCommandException
+ FullyQualifiedErrorId : NoProcessFoundForGivenName,Microsoft.PowerShell.Commands.GetProcessCommand
PS C:\> echo $?
False
Run Code Online (Sandbox Code Playgroud)Run Code Online (Sandbox Code Playgroud)C:\Users\himanshu.agrawal>docker info Client: Debug Mode: false Plugins: scan: Docker Scan (Docker Inc., v0.3.4) Server: Containers: 1 Running: 0 Paused: 0 Stopped: 1 Images: 2 Server Version: 19.03.13 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 8fba4e9a7d01810a393d5d25a3621dc101981175 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd init version: fec3683 Security Options: seccomp Profile: default Kernel Version: 5.4.39-linuxkit Operating System: Docker Desktop OSType: linux Architecture: x86_64 CPUs: 2 Total Memory: 1.915GiB Name: docker-desktop ID: HHIB:HQRB:7VBA:LBUY:HKVJ:LFZ3:FSWZ:4ARP:74ZB:TIWO:WTMG:LHZH Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false Product License: Community Engine
Run Code Online (Sandbox Code Playgroud)PS C:\Users\himanshu.agrawal> Get-Process 'com.docker.proxy' Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName ------- ------ ----- ----- ------ -- -- ----------- 178 15 22984 25172 0.77 14224 1 com.docker.proxy
sudo systemctl is-active docker或sudo status docker或sudo service docker status,或使用 Windows 实用程序检查服务状态。ps最后,您可以使用或 等命令检查“dockerd”进程的进程列表top。| 归档时间: |
|
| 查看次数: |
26098 次 |
| 最近记录: |