Задавате shm_size
в build
, това просто ще засегне изграждането, трябва да го зададете на ниво на обслужване, както следва:
docker-compose.yaml:
version: "3.6"
services:
#other services go here..
postgres:
restart: always
image: postgres:10
hostname: postgres
container_name: fiware-postgres
expose:
- "5432"
ports:
- "5432:5432"
networks:
- default
environment:
- "POSTGRES_PASSWORD=password"
- "POSTGRES_USER=postgres"
- "POSTGRES_DB=postgres"
volumes:
- ./postgres-data:/var/lib/postgresql/data
build:
context: .
shm_size: 256mb
shm_size: 512mb
Dockerfile:
FROM postgres:10
RUN df -h | grep shm
След това docker-compose up -d --build
за да го стартирате и проверете:
[email protected]:~/66$ docker-compose --version
docker-compose version 1.24.0, build 0aa59064
[email protected]:~/66$ docker-compose up -d --build
Building postgres
Step 1/2 : FROM postgres:10
---> 0959974989f8
Step 2/2 : RUN df -h | grep shm
---> Running in 25d341cfde9c
shm 256M 0 256M 0% /dev/shm
Removing intermediate container 25d341cfde9c
---> 1637f1afcb81
Successfully built 1637f1afcb81
Successfully tagged postgres:10
Recreating fiware-postgres ... done
[email protected]:~/66$ docker exec -it fiware-postgres df -h | grep shm
shm 512M 8.0K 512M 1% /dev/shm
Можете да видите във времето за изграждане показва 256m
, но контейнерът по време на изпълнение показва 512m
.