主機環境 ubuntu16.04php
curl -sSL https://get.daocloud.io/docker >>install.sh sh install.sh --mirror Aliyun
root@base2018:/home/tb# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world ca4f61b1923c: Pulling fs layer docker: error pulling image configuration: Get https://dseasb33srnrn.cloudfront.net/registry-v2/docker/registry/v2/blobs/sha256/f2/f2a91732366c0332ccd7afd2a5c4ff2b9af81f549370f7a19acd460f87686bc7/data?Expires=1523309522&Signature=Infe2tgv51xWB5QQA0EaDmJv0ETkvaewuieEpDGkLlMKQR9a4Seglpmk1sJhFkypTPUWBwvfUK6JIem5Jiwk1J9PITbvuTAs3w55weLM3cy3TaGF3so5QJgQKY9TsAaQ7Zi9qnLaZ8PexJlF9lkSvFEP7KiW640m72n6MzMVBoM_&Key-Pair-Id=APKAJECH5M7VWIS5YZ6Q: net/http: TLS handshake timeout. See 'docker run --help'.
出現net/http: TLS handshake timeout,通常是鏡像在牆外,夠不着手。html
root@base2018:/home/tb# vim /etc/docker/daemon.json
內容以下:nginx
{ "registry-mirrors": ["https://registry.docker-cn.com"] }
而後重啓docker,看看狀態web
root@base2018:/home/tb# service docker stop root@base2018:/home/tb# service docker start root@base2018:/home/tb# service docker status
root@base2018:/home/tb# docker run hello-world 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://cloud.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/
從phpdocker.io構件本身須要的php環境,generate project archive以後是一個zip包,裏面內容大概以下docker
root@base2018:/home/tb# unzip xincron.zip Archive: mycron.zip inflating: phpdocker/README.md inflating: phpdocker/README.html inflating: phpdocker/php-fpm/Dockerfile inflating: phpdocker/php-fpm/php-ini-overrides.ini inflating: phpdocker/nginx/nginx.conf inflating: docker-compose.yml
而後須要在能引用到docker-compose.yml 的地方,執行json
root@base2018:/home/tb# docker-compose up The program 'docker-compose' is currently not installed. You can install it by typing: apt install docker-compose
沒有安裝docker-compose,那麼安裝一下,注意用的是daocloude的鏡像ubuntu
root@base2018:/home/tb# curl -L https://get.daocloud.io/docker/compose/releases/download/1.20.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 423 100 423 0 0 2887 0 --:--:-- --:--:-- --:--:-- 2897 100 10.3M 100 10.3M 0 0 1019k 0 0:00:10 0:00:10 --:--:-- 1882k root@base2018:/home/tb# chmod +x /usr/local/bin/docker-compose
再次 docker-compose up
,通過如下輸出。等待。。vim
root@base2018:/home/tb# docker-compose up Creating network "tb_default" with the default driver Pulling webserver (nginx:alpine)... alpine: Pulling from library/nginx ff3a5c916c92: Pull complete f9c32daa8fe9: Pull complete 655cd391f0aa: Pull complete 64b82947328a: Pull complete Digest: sha256:e0f3f5ebde753fa44b5fcdc771fc89f117ee8b2bbcece1c1bdf35f2de4da4e0b Status: Downloaded newer image for nginx:alpine Building php-fpm Step 1/3 : FROM phpdockerio/php56-fpm:latest latest: Pulling from phpdockerio/php56-fpm f2b6b4884fc8: Pull complete c70792025682: Pull complete 4f4f46587b8b: Pull complete 2a42286c9da1: Pull complete 4c18e6e61b91: Pull complete Digest: sha256:f7b330cab7f5dd6101b4824990c9bf4af5e78c3ea1d7c8259e84f5ddd3bd6608 Status: Downloaded newer image for phpdockerio/php56-fpm:latest ---> e944c32c61aa Step 2/3 : WORKDIR "/application" Removing intermediate container 297a0cbcbcc5 ...
root@base2018:/home/tb# docker-compose ps Name Command State Ports --------------------------------------------------------------------------------- xincron-php-fpm /bin/sh -c /usr/sbin/php5- ... Up 9000/tcp xincron-webserver nginx -g daemon off; Up 0.0.0.0:8056->80/tcp
這裏對比一下剛剛壓縮包裏的配置文件segmentfault
version: "3.1" services: webserver: image: nginx:alpine container_name: xincron-webserver working_dir: /application volumes: - .:/application - ./phpdocker/nginx/nginx.conf:/etc/nginx/conf.d/default.conf ports: - "8056:80" php-fpm: build: phpdocker/php-fpm container_name: xincron-php-fpm working_dir: /application volumes: - .:/application - ./phpdocker/php-fpm/php-ini-overrides.ini:/etc/php5/fpm/conf.d/99-overrides.ini
對比一下能夠發現一些東西,對吧。bash
root@base2018:/home/tb# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2916156f654e nginx:latest "nginx -g 'daemon of…" About a minute ago Exited (0) 19 seconds ago unruffled_mcnulty e9d2470dfdf9 nginx:latest "nginx -g 'daemon of…" 5 minutes ago Exited (0) 4 minutes ago quizzical_thompson 69f97e182e72 nginx "nginx -g 'daemon of…" 25 minutes ago Exited (0) 4 minutes ago festive_fermat 44bcd14133af nginx:alpine "nginx -g 'daemon of…" 37 minutes ago Exited (0) 12 seconds ago xincron-webserver 3195a5d6b6e4 tb_php-fpm "/bin/sh -c '/usr/sb…" 37 minutes ago Exited (137) 9 seconds ago xincron-php-fpm 610b22716262 hello-world "/hello" About an hour ago Exited (0) About an hour ago epic_archimedes ef7be27e9f00 hello-world "/hello" About an hour ago Exited (0) About an hour ago nostalgic_lamport
root@base2018:/home/tb# docker run -tid nginx:latest /bin/bash
root@base2018:/home/tb# docker attach cfd496533308 root@cfd496533308:/# ls bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var root@cfd496533308:/#