Home > Back-end >  How can I add folders and files to a docker container running on ECS?
How can I add folders and files to a docker container running on ECS?

Time:08-09

Assuming I have the following docker-compose

version: "3.9"

services:
  skyrimserver:
    container_name: skyrimserver
    image: tiltedphoques/st-reborn-server:latest
    ports:
      - "10578:10578/udp"
    volumes:
     - /opt/docker/skyrimserver/config:/home/server/config
     - /opt/docker/skyrimserver/logs:/home/server/logs
     - /opt/docker/skyrimserver/Data:/home/server/Data
    restart: unless-stopped

I would like to have the folders specified under volumes created & filled with some files before running it. It seems like the docker integration creates a EFS file system automatically which is empty. How can I hook into that to add files upon creation?

EDIT: A nice solution would be to have the ability to change the config on-the-fly and reloading within the game, not having to restart the whole server because the new docker file includes new configuration files

CodePudding user response:

docker compose is a tool to define run docker. When you define volumes in yaml file it's similar to run docker with arg --mount and there is no volume in that instance for you to mount.

What you need with ECS is a fully functioning image with all sources of files in it, using a Dockerfile like this to build image might work:

FROM tiltedphoques/st-reborn-server

CP /opt/docker/skyrimserver/config /home/server/config
CP /opt/docker/skyrimserver/logs /home/server/logs
CP /opt/docker/skyrimserver/Data /home/server/Data

EXPOSE 10578

Edit: In case you still want to use ECS, you can try to SSH to that container or use system manager to connect to container and put your file in /home/server/. I strongly AGAINST this method because EFS is ridiculously slow without dump data.

You should change to use EBS backed EC2 instances. It's easy to scale with auto scaling group and suit your usecase

CodePudding user response:

Hi hope this would help just pu dot infront of you location:

version: "3.9"

services: skyrimserver:

container_name: skyrimserver
image: tiltedphoques/st-reborn-server:latest
ports:
  - "10578:10578/udp"
volumes:
 - ./opt/docker/skyrimserver/config:/home/server/config
 - ./opt/docker/skyrimserver/logs:/home/server/logs
 - ./opt/docker/skyrimserver/Data:/home/server/Data
restart: unless-stopped
  • Related