Docker Modify Docker storage location Modify container image size limit operation

Docker Modify Docker storage location Modify container image size limit operation

This seems to be no longer possible with the new version and is not recommended.

If not, you can directly use soft link to modify the storage location.

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 is deprecated after version 17.0. Now it is recommended to use –data-root

Additional knowledge: Docker orchestration tool uses docker-compose

Install 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 the configuration file, comment out metalink, and uncomment baseurl

Operation Command

Compose operation container (be sure to enter the configuration file directory)

Start the container in the background: docker-compose up -d

Check the running status of the container: docker-compose ps

Stop and delete the container: docker-compose down

Stop and remove the container and delete the volume: docker-compose down --volumes

Stop and start the container: docker-compose stop; docker-compose start

Use of docker-compose exec: docker-compose exec redis bash

Summarize:

To operate docker-compose, you must operate in the path of the configuration file docker-compose.yml

Be sure to pay attention to the format, the space should be a space

Configuration Files

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", the default is bridge

Practice: Simulate the construction of a personal blog

wordpress free blogging 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) first before it can 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

The above Docker changes the docker storage location and changes the container image size limit operation is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM.

You may also be interested in:
  • Docker and iptables and implementation of bridge mode network isolation and communication operations
  • Network management and network isolation implementation of Docker containers
  • How to isolate users in docker containers
  • How to use Docker to limit container resources
  • Implementation of Docker CPU Limit
  • How Docker limits the CPU available to containers
  • How to limit the memory available to a container in Docker
  • Introduction to Docker Isolation and Restriction Principles

<<:  How to implement HTML to detect that input is complete and automatically fill in the next content

>>:  Vue: Detailed explanation of memory leaks

Recommend

How to change the website accessed by http to https in nginx

Table of contents 1. Background 2. Prerequisites ...

Examples of preview functions for various types of files in vue3

Table of contents Preface 1. Preview of office do...

Summary of web design experience and skills

■ Website theme planning Be careful not to make yo...

How to customize Docker images using Dockerfile

Customizing images using Dockerfile Image customi...

Summary of uncommon operators and operators in js

Summary of common operators and operators in java...

Summary of commonly used tags in HTML (must read)

Content Detail Tags: <h1>~<h6>Title T...

Web Design Summary

<br />From the birth of my first personal pa...

How to set horizontal navigation structure in Html

This article shares with you two methods of setti...

JavaScript to achieve all or reverse selection function

This article shares the specific code of JavaScri...

About WSL configuration and modification issues in Docker

https://docs.microsoft.com/en-us/windows/wsl/wsl-...

html+css+js to realize the function of photo preview and upload picture

Preface: When we are making web pages, we often n...

Deployment and configuration of Apache service under Linux

Table of contents 1 The role of Apache 2 Apache I...

...

Example code for configuring monitoring items and aggregated graphics in Zabbix

1. Install Zabbix Agent to monitor the local mach...