docker 部署常用环境

常用命令

service docker start 启动docker镜像

docker images 查看本地镜像

docker ps 查看运行中镜像

docker ps -a 查看所有镜像(包含停止运行)

docker logs 镜像名 查看docker日志 镜像无法启动可查看原因

环境快速部署

mysql

  1. docker pull mysql:5.7
  2. docker run --name mysql -p 3306:3306 -v /home/mysql/data:/var/lib/mysql -v /home/mysql/conf.d:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7

nginx

  1. docker pull nginx
  2. docker run --name nginx -p 80:80 -d nginx
  3. mkdir -p /home/nginx/www /home/nginx/logs /home/nginx/conf
  4. docker cp fc7f5e73ef52:/etc/nginx/nginx.conf /home/nginx/conf
  5. docker run -d -p 80:80 --name nginx -v /home/nginx/www:/usr/share/nginx/html -v /home/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /home/nginx/logs:/var/log/nginx nginx

redis

  1. docker pull redis
  2. 需先在/home/redis创建redis.conf
    模板官方下载 http://download.redis.io/redis-stable/redis.conf
  3. docker run -p 6379:6379 --name redis -v /home/redis/redis.conf:/etc/redis/redis.conf -v /home/redis/docker/data:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes

rabbitMq

  1. docker pull rabbitmq:management

  2. docker run -d --hostname my-rabbit --name rabbit -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=123456 -p 15672:15672 -p 5672:5672 rabbitmq:management

你可能感兴趣的:(docker,linux,nginx,mysql,redis)