1

My program creates folders on "~/" if the OS is linux (Which is the case, considering the ECS Instance):

if platform == "linux" or platform == "linux2":
    appdata = "~/"
else:
    appdata = os.getenv("APPDATA")
log_path = appdata + f"/concil/{parsed_args.acquirer}/logs"
cache_path = appdata + f"/concil/{parsed_args.acquirer}/cache"
pathlib.Path(log_path).mkdir(parents=True, exist_ok=True)

When I connect to the ECS Instance via SSH, even though the Task Definition is running, I can't find any files (And the software should create them normally). What I find weird is that on my Dockerfile:

FROM python:3

COPY requirements.txt /tmp
WORKDIR /tmp
RUN pip install -r requirements.txt --default-timeout=100

COPY . /app
RUN make /app
WORKDIR /app

ENV AWS_ACCESS_KEY_ID=??????????????????
ENV AWS_SECRET_ACCESS_KEY=????????????????????????????????????
ENV AWS_DEFAULT_REGION=us-west-1

CMD [ "python", "./InputDataController/main.py", "--acquirer", "adyen", "-all" ]

I copy the contents to an "/app" folder, which is completely non-existent on the ECS Instance. I can't see any docker-related logs, I can't see the output of my program, yet it is running normally. How can I check the files being saved on the container?

Ericson Willians
  • 7,606
  • 11
  • 63
  • 114
  • Maybe I'm misunderstanding, but are you binding any directories from the ECS instance to the docker container? If you aren't, you won't be able to see ANY of your file system, unless you SSH into the container. – Preston Martin Nov 01 '18 at 15:27
  • No, I thought the ECS instance was the same as the container in the Amazon structure. No idea how to do that, I'll explore the docs further, haven't seen anything related. – Ericson Willians Nov 01 '18 at 15:57
  • The Container Instance and EC2 Instance have the same public DNS. This is confusing, I thought I was connecting to the docker container created with the image, not an "empty" virtual machine. – Ericson Willians Nov 01 '18 at 16:11
  • 1
    Yes, this is because your docker container is running ON the EC2 instance. Try running the command "docker ps". You should see a container id. Then run "docker attach BKD78VHX" or whatever your container id is. – Preston Martin Nov 01 '18 at 16:16
  • 2
    Thank you VERY VERY much Sir, I got it now. Managed to access the running container using ['docker exec -it name-of-container bash'](https://stackoverflow.com/a/40324326/1795924), I guess it was my ignorance concerning how docker works. – Ericson Willians Nov 01 '18 at 16:47
  • I suppose that is one way to do it. Using the docker attach method that I previously listed should work as well as long as the container is running on the instance. – Preston Martin Nov 01 '18 at 16:54

1 Answers1

0

Answer for anyone in the future, if you are looking for this.

I am sharing my experience. After logging in to the EC2 server that is running the containers, I tried to find everywhere but didn't find my file, though my site is working perfectly. After reading @Ericson Willian's comment above, I did

docker-compose bash -it <my_container_name> bash

and landed in the WORKDIR I set in my docker file.

Ariful Haque
  • 3,662
  • 5
  • 37
  • 59