The docker-compose startup file 'docker-compose.yml' is as follows (some information is omitted):
version: '2'
services:
container_1:
image: ...
ports: ...
command: /worker/bin/init.sh
volumes: ...
extra_hosts: ...
restart: always
network: ...
cap_add:
- SYS_ADMIN
- SYS_PTRACE
Then I start the container using below command:
docker-compose -f docker-compose.yml up -d
The second way to get into the container to execute commands is actually based on docker-compose, since I need to specify a lot of port mappings and file mappings, it's complicated to start using the command line. I modified the command in the above yml file to (in order to keep the container running):
command: vim tmpfile
Starting the container using the same method, and use the following method to enter the container:
docker exec -ti container_1 bash
Finally execute the script (/worker/bin/init.sh) manually.
When using the first method, I encountered a strange problem. After executing the 'init.sh' script, the permissions of some files in the container were modified, and the read permissions of these files were removed. But after executing the same script using method 2, nothing has changed.
Has anyone encountered a similar problem? thank you for your reply.