docker的常用命令及常用中间件配置(持续补充ing)
Docker的常见命令包括:
- 创建容器:
docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
- 查看容器:
docker ps [OPTIONS]
- 停止/启动容器:
docker stop [OPTIONS] CONTAINER [CONTAINER...]
docker start [OPTIONS] CONTAINER [CONTAINER...]
- 删除容器:
docker rm [OPTIONS] CONTAINER [CONTAINER...]
- 查看容器日志:
docker logs [OPTIONS] CONTAINER
- 进入容器:
docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
- 构建镜像:
docker build [OPTIONS] PATH | URL | -
- 推送镜像:
docker push [OPTIONS] NAME[:TAG]
- 拉取镜像:
docker pull [OPTIONS] NAME[:TAG|@DIGEST]
- 查看镜像:
docker images [OPTIONS] [REPOSITORY[:TAG]]
- 删除镜像:
docker rmi [OPTIONS] IMAGE [IMAGE...]
- 保存镜像到本地文件:
docker save [OPTIONS] IMAGE [IMAGE...]
- 加载本地镜像文件:
docker load [OPTIONS]
常见的Docker中间件配置包括但不限于:
- Nginx配置:
server {
listen 80;
server_name yourdomain.com;
location / {
proxy_pass http://your_backend:port;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
- Redis配置:
# 设置密码
requirepass yourpassword
# 设置持久化
save 900 1
save 300 10
save 60 10000
- MySQL配置:
[mysqld]
bind-address = 0.0.0.0
port = 3306
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
- MongoDB配置:
# mongod.conf
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
net:
port: 27017
bindIp: 0.0.0.0
- PHP-FPM配置:
[global]
pid = /var/run/php/php7.4-fpm.pid
error_log = /var/log/php7.4-fpm.log
include = etc/php-fpm.d/*.conf
[www]
user = www-data
group = www-data
listen = /run/php/php7.4-fpm.sock
- Elasticsearch配置:
cluster.name: my-cluster
node.name: node-1
network.host: 0.0.0.0
http.port: 9200
评论已关闭