dockers
常用docker命令
管理命令
docker ps // 查看所有正在运行容器
docker stop containerId // containerId 是容器的ID
docker ps -a // 查看所有容器 $ docker ps -a -q // 查看所有容器ID
docker stop $(docker ps -a -q) // stop停止所有容器
docker rm $(docker ps -a -q) // remove删除所有容器
docker restart 容器id //重启容器
eg:
docker run -d -p 8008:80 --name nginx-name nginx:1.1.1 //启动一个新docker实例(nginx:1.1.1是版本号)
指令ps说明 https://www.runoob.com/docker/docker-ps-command.html
指令exec说明 https://www.runoob.com/docker/docker-exec-command.html
容器状态(进阶) https://blog.csdn.net/weixin_33656238/article/details/113630124
目录端口映射
-p: 指定端口映射,格式为:主机(宿主)端口:容器端口
--privileged=true 关闭安全权限,否则你容器操作文件夹没有权限
-v 挂载目录为:主机目录:容器目录,在创建前容器是没有指定目录时,docker 容器会自己创建
eg:
docker run -p 8079:80 --name nginx-test
--privileged=true
-v /testdocker/default.conf:/etc/nginx/conf.d/default.conf
-v /testdocker/html:/usr/share/nginx/html -d nginx:1.14
常用dockers
gitlab
docker run `
--detach `
--hostname 121.5.151.29:11080 `
--publish 11443:443 --publish 11080:11080 --publish 11022:22 `
--name gitlab `
--volume $env:GITLAB_HOME/config:/etc/gitlab `
--volume $env:GITLAB_HOME/logs:/var/log/gitlab `
--volume $env:GITLAB_HOME/data:/var/opt/gitlab `
gitlab/gitlab-ce:13.10.2-ce.0
rabbitmq
docker run -itd --name rabbitmq -p 5672:5672 -p 15672:15672 -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=novabeyond rabbitmq:3-management
redis
docker run -itd --name myredis -p 6379:6379 -v C:/data/redis/conf:/usr/local/etc/redis redis redis-server /usr/local/etc/redis/redis.conf
配置文件中注释掉 bind 127.0.0.1 添加密码行: requirepass xxxx
mysql
5.6
docker run --name some-mysql -v /C/data/mysql/conf:/etc/mysql:ro -v /C/data/mysql/data:/var/lib/mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=Nov2014 -e TZ=Asia/Shanghai -d mysql:5.6
配置文件读写
docker run --name some-mysql -v /C/users/data/mysql/conf:/etc/mysql:rw -v /C/users/data/mysql/data:/var/lib/mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=Nov2014 -e TZ=Asia/Shanghai -d mysql:5.6
注意:windows环境docker下mysql配置文件映射路径需要放到C:(否则会报777权限的配置文件, 配置文件会被忽略), 并需要给users目录下相关文件夹加users用户组的修改权限.
8.0
docker run --name mysql8 -v /C/users/data/mysql8/conf:/etc/mysql:rw -v /C/users/data/mysql8/data/mysql:/var/lib/mysql -v /C/users/data/mysql8/data/mysql-files:/var/lib/mysql-files -p 3307:3306 -e MYSQL_ROOT_PASSWORD=Nov2014 -e TZ=Asia/Shanghai -d mysql:8.0
jfrog
docker run --name jfrog-oss -d -v data_artifactory:/var/opt/jfrog/artifactory -p 8081:8081 -p 8082:8082 -p 8046:8046 -p 8049:8049 -p 8070:8070 docker.bintray.io/jfrog/artifactory-oss
,帮我试下
sqlserver
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=w12345678" -p 1433:1433 -v /C/data/mssql:/var/opt/mssql -d mcr.microsoft.com/mssql/server:2019-latest
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=mssql@2021" -p 1433:1433 -v /C/data/mssql/data:/var/opt/mssql/data -v /C/data/mssql/log:/var/mssql/log -v /C/data/mssql/secrets:/var/opt/mssql/secrets -d mcr.microsoft.com/mssql/server:2019-latest
docker使用
标签:dockers,run,--,mysql,var,docker,data From: https://www.cnblogs.com/w784319947/p/16856162.htmlsudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu
$(lsb_release -cs)
stable"apt-get update
apt-get install apt-transport-https ca-certificates curl
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
apt-get install docker-ce
docker --version
docker pull redis:3.2.8
docker run --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=Nov2014 --restart=always -d -v /usr/local/mysql/data:/var/lib/mysql -v /usr/local/mysql/log:/var/log/mysql -v /etc/localtime:/etc/localtime -v /usr/local/mysql/conf/my.cnf:/etc/mysql/my.cnf mysql:5.6.24
docker ps -s
docker ps -a
docker images
docker exec -it mysql /bin/bash