Docker容器安装方法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/q601115211/article/details/81193964

下载Docker

链接:https://www.docker.com/community-edition
需要先注册才能下载,注册时因为有谷歌人机验证需要翻墙。怕麻烦或不会弄的可以直接我放在百度云盘的Docker。

链接:https://pan.baidu.com/s/11JJ0xpuCU7MANr1k6OF87A 密码:raq7

安装Docker

安装按提示步骤可以顺利安装。

检查Docker版本

确保您的docker、docker-compose和docker-machine版本是最新的,并且与Docker.app兼容。如果运行不同的版本,输出可能会有所不同。

$ docker --version
Docker version 18.03.1-ce, build 9ee9f40

$ docker-compose --version
docker-compose version 1.21.1, build 5a3f1a3


$ docker-machine --version
docker-machine version 0.14.0, build 89b8332

验证Docker

打开一个命令行终端,通过运行简单的Docker映像hello-world来测试您的安装是否有效:
启动Dockerized Web服务器。如果在本地找不到镜像,Docker会从Docker Hub中取出它。

  1. 执行报错了
docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/library/hello-world/manifests/latest: unauthorized: incorrect username or password.
See 'docker run --help'.

修改成国内源

vim daemon.json
# 增加
 "registry-mirrors": ["https://registry.docker-cn.com"]  

重启Docker

docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9db2ca6ccae0: Pull complete 
Digest: sha256:4b8ff392a12ed9ea17784bd3c9a8b1fa3299cac44aca35a85c90c5e3c7afacdc
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.
    (amd64)
 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://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/engine/userguide/

Docker基本使用方法

  1. 查看容器的详细信息
docker container ls

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
  1. 使用以下命令停止并删除容器和图像。使用“all”标志(–all或-a)查看已停止的容器。
$ docker container ls
$ docker container stop webserver
$ docker container ls -a
$ docker container rm webserver
$ docker image ls
$ docker image rm hello-world

详细见官方文档
https://docs.docker.com/docker-for-mac/#add-client-certificates

猜你喜欢

转载自blog.csdn.net/q601115211/article/details/81193964