码迷,mamicode.com
首页 > 其他好文 > 详细

docker操作

时间:2017-06-12 22:19:13      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:docker操作

======================================================

==============安装Docker-EE ==========================

1. open url https://www.docker.com/enterprise-edition

2. 选择平台,登录store.docker.com

3. 复制DOCKER-EE-URL

#4. rm -rf /etc/yum.repo/docker*.repo

5. sh -c ‘echo "DOCKER-EE-URL" > /etc/yum/vars/dockerurl‘

6. yum install -y yum-utils

7. yum-config-manager --add-repo DOCKER-EE-URL/docker-ee.repo

8. yum install docker-ee 

9. systemctl start docker 


====================================================

============ 安装docker-engine ======================

cat >/etc/yum.repos.d/docker.repo <<-EOF

[dockerrepo]

name=Docker Repository 

baseurl=https://yum.dockerproject.org/repo/main/centos/7 

enabled=1

gpgcheck=1 

gpgkey=https://yum.dockerproject.org/gpg 

EOF


#=====================================================

#==============docker=================================

#yum install docker -y

#docker version

#设置docker 代理(版本不同,配置不同)

#vi /etc/systemd/system/docker.service.d/http_proxy.conf

# [service]

# Environment="HTTP_PROXY=http://IP:PORT"

# Environment="HTTPS_PROXY=http://IP:PORT"

# wq

#vi /usr/lib/systemd/system/docker.service

# [service]

# Environment="HTTP_PROXY=http://IP:PORT"

# Environment="HTTPS_PROXY=http://IP:PORT"


#vi /etc/sysconfig/docker

# OPTIONS=‘--selinux-enabled


#======================================================

#===========建立目录并授权=============================

mkdir -p /var/log/eb-rest 

mkdir -p /var/log/mongo

mkdir -p /var/log/mysql

mkdir -p var/log/php-fpm

#======================================================

#============INSTALL PHP===============================

docker pull php

mkdir -p /etc/php-fpm.d/ /var/lib/php


docker run --name=php-fpm -p 9000:9000 -d -v /var/log/php-fpm:/var/log/php-fpm -v /var/www/eb-web/:/var/www/eb-web -v /var/lib/php/:/var/lib/php -v /etc/php-fpm.d:/etc/php-fpm.d --privileged=true php:5.6-fpm

#======================================================

#===========docker pull nginx==========================

docker pull nginx && docker pull mysql

mkdir -p /etc/nginx/conf.d

vi /etc/nginx/nginx.conf

vi /etc/nginx/mime.types

docker run --name=nginxsv1 -p 80:80 -p 443:443 --link php-fpm:php-fpm --privileged=true -v /etc/nginx/:/etc/nginx/ -v /var/www/:/var/www -v /var/log/nginx/:/var/log/nginx/ -d nginx

#docker run --rm=true -it --privileged=true -v /etc/nginx/:/etc/nginx/ nginx /bin/bash #(可以写入挂载目录,退出后删除容器)

#docker run --name=nginxsv1 -p 80:80 -p 443:443 --privileged=true -v /var/log/nginx/:/var/log/nginx/ -d nginx  #(可以写入挂载目录,后台运行)

#docker run -it -v /var/www/eb-web/:/var/www/ -v /etc/nginx/:/etc/nginx/ --privileged=true nginx

#删除容器

docker ps -a

docker stop <CONTAINER ID>

docker rm <CONTAINER ID>


docker rmi <IMAGE ID>



#======================================================

#============INSTALL DB================================

docker pull percona:5.6

mkdir -p /etc/mysql/conf /var/lib/mysql/masterdb/db/ /var/lib/mysql/slavedb/conf /var/log/mysql/master/ /var/log/mysql/slave 

chown -R mysql:mysql /etc/mysql/conf /var/lib/mysql/masterdb/db/ /var/lib/mysql/slavedb/conf /var/log/mysql/master/ /var/log/mysql/slave


docker run  --name=masterdb -p 3306:3306 -v /etc/mysql/:etc/mysql/ -e MYSQL_ROOT_PASSWORD=28270033 -d percona:5.6


#======================================================

#============dockerfile================================


#build PHP5.6

FROM daocloud.io/php:5.6-cli

COPY . /usr/src/myapp

WORKDIR /usr/src/myapp

CMD [ "php", "./your-script.php" ]

docker build -t my-php-app .

docker run -it --rm --name my-running-app my-php-app



#不使用dockerfile

docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w /usr/src/myapp daocloud.io/php:5.6-cli php your-script.php

#构建Apache

#FROM daocloud.io/php:5.6-apache

#COPY config/php.ini /usr/local/etc/php  #新建php.ini 并复制

#COPY src/ /var/www/html/   #src包含所有的PHP代码

docker build -t my-php-app .

docker run -it --rm --name my-running-app my-php-app


#不使用dockerfile

docker run -it --rm --name my-apache-php-app -v "$PWD":/var/www/html daocloud.io/php:5.6-apache



#dockerfile 指令

FROM 


EXPOSE 22

#检查安装的容器

docker images



#安装Java

docker pull java:java  

docker run -it java java -version


#建立MySQL

docker create --name mysqlsrv1 -e MYSQL_ROOT_PASSWORD=123456 -P 3306:3306 mysql  

docker start mysqlsrv1

docker ps

netstat -tlp


#进入MySQL环境

docker exec -it mysqlsrv1 /bin/bash


#安装NGINX



# 搭建私有仓库

mkdir -p /docker/data

docker pull registry

docker run -it --name registry -p 5000:5000 -v /docker/data:/tmp/registry registry


后续操作可留言

docker操作

标签:docker操作

原文地址:http://xunmeng.blog.51cto.com/1092116/1934647

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!