1 下载docker安装包 https://download.docker.com/win/stable/InstallDocker.msi
2 开启win10的Hyper-V ,控制面板 -> 程序 -> 启用或关闭Windows功能 -> 选中Hyper-V,然后重启电脑生效。
3 安装docker工具包
通过命令:docker run -it ubuntu bash 进入命令行编辑页面。
4执行命令下载helloworld和nginx
C:\Users\j>docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 17.06.0-ce
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 logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfb82a876ecc11b5ca0977d1733adbe58599088a
runc version: 2d41c047c83e09a6d61d464906feb2a2f3c52aa4
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.36-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: moby
ID: RQ4H:EOQD:RVYQ:DQ2P:56XQ:VRYI:T2HW:WCOA:G67B:XT5V:SOSL:BQS6
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 15
Goroutines: 24
System Time: 2017-07-29T01:58:58.7920232Z
EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
C:\Users\j>docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b04784fba78d: Pull complete
Digest: sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://cloud.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/
C:\Users\j>docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest 1815c82652c0 6 weeks ago 1.84kB
C:\Users\j>docker run hellow-world
Unable to find image 'hellow-world:latest' locally
docker: Error response from daemon: repository hellow-world not found: does not exist or no pull access.
See 'docker run --help'.
C:\Users\j>docker run -it ubuntu bash
Unable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
e0a742c2abfd: Pull complete
486cb8339a27: Pull complete
dc6f0d824617: Pull complete
4f7a5649a30e: Pull complete
672363445ad2: Pull complete
Digest: sha256:84c334414e2bfdcae99509a6add166bbb4fa4041dc3fa6af08046a66fed3005f
Status: Downloaded newer image for ubuntu:latest
root@5a3d50b6a43a:/# ps aux
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.1 0.1 18240 3292 pts/0 Ss 02:02 0:00 bash
root 10 0.0 0.1 34424 2908 pts/0 R+ 02:02 0:00 ps aux
root@5a3d50b6a43a:/# docker ps -a
bash: docker: command not found
root@5a3d50b6a43a:/# exit
exit
C:\Users\j>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5a3d50b6a43a ubuntu "bash" 52 seconds ago Exited (127) 7 seconds ago nervous_mirzakhani
4f8f66cb2326 hello-world "/hello" 3 minutes ago Exited (0) 3 minutes ago blissful_pare
C:\Users\j>docker run -d -p 81:80 --name webserver nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
94ed0c431eb5: Pull complete
9406c100a1c3: Pull complete
aa74daafd50c: Pull complete
Digest: sha256:788fa27763db6d69ad3444e8ba72f947df9e7e163bad7c1f5614f8fd27a311c3
Status: Downloaded newer image for nginx:latest
e1756eebd18df374a25380617769703efea8e97e6a210605049b014716c0e525
C:\Users\j>docker -ps
unknown shorthand flag: 'p' in -ps
See 'docker --help'.
Usage: docker COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default
"C:\Users\j\.docker")
-D, --debug Enable debug mode
--help Print usage
-H, --host list Daemon socket(s) to connect to
-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
"C:\Users\j\.docker\ca.pem")
--tlscert string Path to TLS certificate file (default
"C:\Users\j\.docker\cert.pem")
--tlskey string Path to TLS key file (default
"C:\Users\j\.docker\key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Management Commands:
checkpoint Manage checkpoints
config Manage Docker configs
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 local standard input, output, and error streams 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
deploy Deploy a new stack or update an existing stack
diff Inspect changes to files or directories 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.
C:\Users\j>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e1756eebd18d nginx "nginx -g 'daemon ..." 10 seconds ago Up 9 seconds 0.0.0.0:81->80/tcp webserver
C:\Users\j>docker run -it ubuntu bash docker run -i -t nginx /bin/bash 运行指定的镜像名如nginx进入base命令行
root@2ef48807423c:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@2ef48807423c:/# cd usr
root@2ef48807423c:/usr# ls
bin games include lib local sbin share src
root@2ef48807423c:/usr# cd ..
root@2ef48807423c:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
root@2ef48807423c:/#
最后通过http://localhost:81/访问启动的nginx镜像服务。