Home > Mobile >  How to get a file in one container that is in another container?
How to get a file in one container that is in another container?

Time:07-27

I have a docker-compose.yml file that describes several containers.

I need to use a file in container C that is in container A.

Tell me, please, how can this be done? I don't understand the examples from the documentation.

CodePudding user response:

If files are under volume, you can access file with your server (root account probably).

Else, you should first:

docker cp container_a:/path/to/file /path/in/your/server
docker cp /path/in/your/server container_c:/path/to/file

CodePudding user response:

1) using Docker volume Here share same asset-volume between two containers

version: '3'
services:
  A:
    volumes:
      - asset-volume:/path/a/assets
  B:
    volumes:
      - asset-volume:/path/b/assets

volumes:
  asset-volume:
  1. Using a host directory Here share same host assets directory between two containers
version: '3'
services:
  A:
    volumes:
      - ./assets:/path/a/assets
  B:
    volumes:
      - ./assets:/path/b/assets
  • Related