Docker安装记录

2018/04/27 Docker 阅读次数:

摘要:安装docker中遇到的问题,方便大家今后安装的时候好处理  

1.下载 docker的ded包 2.安装 sudo dpkg -i .ded 3.运行 sudo docker run hello-world 测试

报一下错误

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pulling fs layer 
docker: error pulling image configuration: Get https://dseasb33srnrn.cloudfront.net/registry-v2/docker/registry/v2/blobs/sha256/e3/e38bc07ac18ee64e6d59cf2eafcdddf9cec2364dfe129fe0af75f1b0194e0c96/data?Expires=1524943858&Signature=JDmRGceAlM6iJb8aIC5cu7mrrsgSysG~Y~IctwjGcAsfM64nEYh6JkmmYxsKItVlIqNbanKXxajcA8QhQqyoLZ8xQxMFOq~5PsfgQlfj8jaSvznGx3~gf0ShjThON4Kh6LorTOP0MkTLvXBTW99yooLM9XZ2583II5dnbw4SCmA_&Key-Pair-Id=APKAJECH5M7VWIS5YZ6Q: net/http: TLS handshake timeout.
See 'docker run --help'.

4.网上的一大堆都不怎么好使,执行下面两行命令

echo "DOCKER_OPTS=\"\$DOCKER_OPTS --registry-mirror=http://f2d6cb40.m.daocloud.io\"" | sudo tee -a /etc/default/docker
sudo service docker restart
再次运行测试命令  5.成功后如下,显示
 
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
9bb5a5d4561a: Pull complete 
Digest: sha256:f5233545e43561214ca4891fd1157e1c3c563316ed8e237750d59bde73361e77
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使用

第一次使用:runoob@runoob:~$ docker run ubuntu:15.10 /bin/echo "Hello world"
它会自动找ubuntu:15.10镜像,没有会自动下载,下载完成后如下图 ![img](/images/assets/docek.png)
  • 进入容器对话功能  

      docker run -i -t ubuntu:15.10 /bin/bash
      通过运行exit命令或者使用CTRL+D来退出容器
    
  • 后台运行  

      docker run -d ubuntu:15.10 /bin/sh -c "while true; do echo hello world; sleep 1; done"
    
  • 查看正在运行的容器  

      docker ps
        
      CONTAINER ID:容器ID
      NAMES:自动分配的容器名称
      在容器内使用docker logs命令,查看容器内的标准输出
    
  • 查看容器的输出

      docker logs CONTAINER ID
      docker logs NAMES
    
  • 停止容器  

      docker stop CONTAINER ID
      docker stop NAMES
    

Search

    Table of Contents