docker守护进程启动的时候,会默认赋予名为docker的用户组读写Unix socket的权限,因此只要创建docker用户组,并将当前用户加入到docker用户组中,那么当前用户就有权限访问Unix socket了,进而也就可以执行docker相关命令
sudo groupadd docker #添加docker用户组
sudo gpasswd -a $USER docker #将登陆用户加入到docker用户组中
newgrp docker #更新用户组
————————————————
版权声明:本文为CSDN博主「152910000」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上> 原文出处链接及本声明。
原文链接:https://blog.csdn.net/icodestechnology/java/article/details/97170540
创建nginx运行容器:
docker run \
--name nginx \
-p 80:80 \
-v /home/oldlie/projects/data/nginx/html:/usr/share/nginx/html \
-v /home/oldlie/projects/data/nginx/nginx.conf:/etc/nginx/nginx.conf \
-v /home/oldlie/projects/data/nginx/conf.d:/etc/nginx/conf.d \
-v /home/oldlie/projects/data/nginx/logs:/var/log/nginx \
-m 256M \
-d nginx
修改完了之后别忘了修改配置文件中的root指向:
location / {
#root html;
root /usr/share/nginx/html;
index index.html index.htm;
}
创建MongoDB
docker run --name mongo -p 27017:27017 -v /home/ray/data/mongo/db:/data/db -d mongo
创建MySQL和PhpMyAdmin
创建tomcat
docker run --name tomcat8 \
-p 8080:8080 \
-v /home/ray/data/tomcat8/conf:/usr/local/tomcat/conf \
-v /home/ray/data/tomcat8/webapps:/usr/local/tomcat/webapps \
-v /home/ray/data/tomcat8/temp:/usr/local/tomcat/temp \
-v /home/ray/data/tomcat8/logs:/usr/local/tomcat/logs \
-d tomcat:8.5.50-jdk8
创建MySQL
docker run \
-p 3306:3306 \
--name mysql56 \
-v /home/oldlie/projects/data/mysql/mysql:/var/lib/mysql \
-v /home/oldlie/projects/data/mysql/logs:/var/log/mysql \
-v /home/oldlie/projects/data/mysql/mysql.conf.d:/etc/mysql/mysql.conf.d \
-e MYSQL_ROOT_PASSWORD=root \
-m 256M \
-d mysql:5.6
创建对应的phpMyAdmin
docker run \
--name pma \
-p 58080:80 \
--link mysql56:db \
-m 128M \
-d phpmyadmin/phpmyadmin