I make my Docker Container in separate mode with the following command:
Docker Run [Options] --name = "my_image" -d Container_name / bin / bash -c "/opt/init.sh"
So let me know "/opt/init.sh" Need to execute what I created in the container I saw that the container is closed after executing the script.
How is the separate container introduced with the execution of scripts / services in the container creation?
There are two ways to run a docking container
- Different modes - this Mode you execute a command and will end the container after the command
- Foreground mode - This mode lets you run a shell shell, but it will end the container even after being out of the shell
What you want background mode is not given in these parameters, but there are several ways to do this.
- Run an infinite command in different modes so that the command does not end and the container never stops. I usually use "tail-f / dev / null" because it is very light weight and / dev / null is present in most Linux images
Docker Run- D - Name = Name Container Tail-f / dev / null
Then you can batch to run the container like this:
Doker exec - Name / bin / Bash -l
If you use the -l parameter, then it will log in as the login mode. Bashrc will implement it like normal bash login. Otherwise, you will have to manually bamboo
- EntryPoint - You can create any scripts such as /entrypoint.sh in Entrypoint.sh you can not finish any
service mysql restart
...
tail -f / dev / null
- It never ends.
This entry.asp, chmod on it + a + x, exit the Doker bash, then start it like this:
Docker Run --name = name Container --entrypoint /entrypoint.sh
This allows each container to get your start script and you attach the start script every time
No comments:
Post a Comment