Update in-docker-compose container with new env_file

  docker, docker-compose

I have the following docker-compose configuration:

version: '2'

services:
  nginx:
    image: 'nginx:latest'
    expose:
      - '80'
      - '8080'
    container_name: nginx
    ports:
      - '80:80'
      - '8080:8080'
    volumes:
      - '/home/ubuntu/nginx.conf:/etc/nginx/nginx.conf'
    networks:
      - default
    restart: always
  
  inmates:
    image: 'xxx/inmates:mysql'
    container_name: 'inmates'
    expose:
      - '3000'
    env_file: './inmates.env'
    volumes:
      - inmates_documents_images:/data
      - inmates_logs:/logs.log
    networks:
      - default
    restart: always

  we19:
    image: 'xxx/we19:dev'
    container_name: 'we19'
    expose:
      - '3000'
    env_file: './we19.env'
    volumes:
      - we19_logs:/logs.log
    networks:
      - default
    restart: always

  desktop:
    image: 'xxx/desktop:dev'
    container_name: 'desktop'
    expose:
      - '3000'
    env_file: './desktop.env'
    volumes:
      - desktop_logs:/logs.log
    networks:
      - default
    restart: always
  
volumes:
  inmates_documents_images:
  inmates_logs:
  desktop_logs:
  we19_logs:

Assume I did docker-compose up -d --buiild.

Now the 4 containers (services) are runnig.

Now, I want to update ./desktop.env file with new content. Is there any possible way to reset only desktop container with the new env file? Or docker-compose restart is neccessary?
Basically I’m trying to restart only desktop container with the new env file but keep all 3 others container up running without restarting them.

Source: Docker Questions

LEAVE A COMMENT