while starting a docker container I have to execute a script inside docker container. Can I do it using docker run command or docker start command mentioning the path in docker? I know I have to use CMD in docker file but dockerfile is not present
Asked
Active
Viewed 1,060 times
-1
-
have you tried docker exec -it mycontainer /bin/bash -c "commands"? – Edcel Cabrera Vista May 05 '20 at 06:40
-
@EdcelCabreraVista docker exec command can be used once the container is running. Anyway i found the solution docker run --name TEST -d
sh -c " CMD " in CMD section you can give the path of shell script – user3906723 May 05 '20 at 13:39
3 Answers
0
To enter a running Docker container (get a Bash prompt inside the container), please run the following:
docker container exec -it <container_id> /bin/bash
You can get the container_id by listing running Docker containers with:
docker container ps -a
or docker ps -a

Paulie-C
- 1,674
- 1
- 13
- 29
0
docker run --name TEST -d image sh -c " CMD "
in CMD section you can give the path of shell script

user3906723
- 117
- 2
- 15