Docker Modify docker Storage Location Modify Container Image Size Limit Operation
- 2021-09-12 02:37:22
- OfStack
The new version seems to be dying, so it is not recommended.
No, you can modify the storage location directly by soft connection.
vim /usr/lib/systemd/system/docker.service
ExecStart=/usr/bin/dockerd --graph=/work/docker_data
--storage-driver devicemapper
--storage-opt dm.loopdatasize=1000G
--storage-opt dm.loopmetadatasize=10G
--storage-opt dm.fs=ext4
--storage-opt dm.basesize=100G
-H fd:// --containerd=/run/containerd/containerd.sock
Supplement 2020.07. 29
graph was obsolete after version 17.0, and now data-root is advocated
Additional knowledge: The docker orchestration tool uses docker-compose
Installing docker-compose
yum install -y epel-release
yum install -y python-pip
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple docker-compose==1.24.1
# If python-pip reports an error
vim/etc/yum. repos. d/epel. repo Modify configuration file, comment out metalink, uncomment baseurl
Operation command
compose Operation Container (1 must enter the profile directory)
Background startup container: docker-compose up-d
View container performance: docker-compose ps
Stop and delete container: docker-compose down
Stop and delete container and delete volume: docker-compose down-volumes
Stop startup container: docker-compose stop; docker-compose start
Use of docker-compose exec: docker-compose exec redis bash
Summary:
Operation docker-compose1 must operate under the configuration file docker-compose. yml file path
Format 1 Be sure to note that this space is a space
Configuration file
docker-compose.yml
version: '3'
services:
nginx:
image: mycentos:nginx
ports:
- "8080:80"
volumes:
- /home:/usr/local/nginx/html
- /var/logs/nginx/logs:/usr/local/nginx/logs
command: /usr/local/nginx/sbin/nginx -g "deamon off;"
redis:
image: mycentos:redis
ports:
- "6380:6379"
If you change to host mode, remove ports and add network_mode: "host", which defaults to bridging
Actual combat: simulating the establishment of personal blog
wordpress Free Blog Platform
docker-compose.yml
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
# Specify environment variables docker -itd -e MYSQL_ROOT_PASSWORD= somewordpress
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on: # 1. Start the above db( Dependency ) To be installed 2.docker link
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}
# Corresponding to the top volumes:
Find Volume Label
docker volume ls
docker volume inspect < volume-id >
Mountpoint Host Path
The corresponding is/var/lib/mysql