docker install and configure

来源:互联网 发布:手机直播软件 编辑:程序博客网 时间:2024/05/21 17:26

docker install and configure


概述

Docker系统有两个程序:docker服务端和docker客户端

ubuntu install docker
文档 https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04

Step 1 — Installing Docker

Update apt and add the key and repo$sudo apt-get update$sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -root#add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"$sudo apt-get updateMake sure you are about to install from the Docker repo instead of the default Ubuntu 16.04 repo:$apt-cache policy docker-ceinstall Docker:$sudo apt-get install -y docker-ceCheck that it's running:$sudo systemctl status docker

Step 2 — Executing the Docker Command Without Sudo (Optional)

add your username to the docker group:$sudo usermod -aG docker ${USER}$su - ${USER}$id -nG$sudo usermod -aG docker username

Step 3 — Using the Docker Command

To view all available subcommands, type:$dockerTo view the switches available to a specific command, type:$docker docker-subcommand --helpTo view system-wide information about Docker, use:$docker info

Step 4 — Working with Docker Images

$docker run hello-world

docker create self images

2. 使用Dockerfile2.1创建镜像所在的文件夹和Dockerfile文件$mkdir sinatra$cd sinatra$touch Dockerfile2.2在Dockerfile文件中写入指令,没一条指令都会更新镜像的信息例如:-># This is a comment->FROM ubuntu:14.04->MAINTAINER Kate Smith ksmith@example.com->RUN apt-get update && apt-get install -y ruby ruby-dev->RUN gem install sinatra格式说明:每行命令都是以 INSTRUCTION statement 形式,就是命令+ 清单的模式。命令要大写,“#”是注解。FROM 命令是告诉docker 我们的镜像什么。MAINTAINER 是描述 镜像的创建人。RUN 命令是在镜像内部执行。就是说他后面的命令应该是针对镜像可以运行的命令。2.3创建镜像命令:docker build -t ouruser/sinatra:v2 .docker build 是docker创建镜像的命令-t 是标识新建的镜像属于 ouruser的sinatra是仓库的名称:v2 是tag“.”是用来指明 我们的使用的Dockerfile文件当前目录的2.4创建完成后,从镜像创建容器$docker run -t -i ouruser/sinatra:v2 /bin/bash

附1

检查docker的版本$docker versionDocker官方网站专门有一个页面来存储所有可用的镜像,网址是:index.docker.io命令行的格式为:$docker search 镜像名字通过docker命令下载tutorial镜像:$docker pull learn/tutorial在docker容器中运行hello world!$docker run learn/tutorial echo "hello word"在容器中安装新的程序, 一个简单的程序(ping)$docker run learn/tutorial apt-get install -y ping获得安装完ping命令之后容器的id$docker ps -l检查运行中的镜像$docker ps查看详细的关于某一个容器的信息$docker inspect 698保存对容器的修改$docker commit 698 learn/ping运行新的镜像$docker run lean/ping ping www.google.com发布自己的镜像$docker push learn/ping

附2
文档 http://www.jianshu.com/p/3384e342502b

sudo docker run -d --name env_php7_coober -v /var/www:/home/coober/www roydejong/php7-xdebugdocker inspect env_php7_coober | grep "IPAddress"docker exec -it env_php7_coober /bin/bashsudo docker cp env_php7_coober:/etc/php/7.0/fpm/pool.d/www.conf ./sudo docker cp  ./www.conf env_php7_coober:/etc/php/7.0/fpm/pool.d/www.conf

supervisor安装配置与使用

服务器启停sudo /etc/init.d/supervisord {start|stop|status|restart|reload|force-reload|condrestart}可以通过supervisorctl查看管理监控的进程情况:supervisor>helpsupervisor>help stopsupervisor> stop publisher_for_summarysupervisor> start publisher_for_summarysupervisor> start allsupervisor> stop allsupervisor> status