Docker Community Forums

Share and learn in the Docker community.

How to know on host OS that a docker container is up

Hi,

I need to execute a script on host OS as soon as a specific container is up.
How would i know on the host OS?

Thanks.

There is no such thing as a post container started hook.

Though, you can listen to docker events to implement something yourself.
Here is a simple bash example on how to work with events: https://github.com/int128/docker-eventhandler/blob/master/eventhandler.sh

On the otherside, If you are experienced with developing applications, you could use the docker sdk of your choice and implement your own event hander for whatever purposes you like.

@meyay thanks for the eventhandler.sh example, it looks i can use it.
Ill get back if i face any issue with it.

Secondly, i am facing a problem with docker-compose environment config.

i need to set up a variable whose value contains a $
Actually its a password of somthing like: ‘abc$def’

environment:
PASS=abc$pqr

the docker config treats $pqr as some variable.

how to set the variable PASS with value ‘abc$pqr’

i tired with PASS=‘abc$pqr’ without success.

Thanks.

Regarding the script: it is not mine.

try $$ instead of . If I remember correctly, it should escape the character.

@meyay That was one of the quickest responses i have ever got!
Thanks, it worked.

Docker Desktop enables you to sign into Docker Hub using two-factor authentication. Two-factor authentication provides an extra layer of security when accessing your Docker Hub account.

You must enable two-factor authentication in Docker Hub before signing into your Docker Hub account through Docker Desktop. For instructions, see Enable two-factor authentication for Docker Hub.

After you have enabled two-factor authentication:

Go to the Docker Desktop menu and then select Sign in / Create Docker ID.

Enter your Docker ID and password and click Sign in.

After you have successfully signed in, Docker Desktop prompts you to enter the authentication code. Enter the six-digit code from your phone and then click Verify.

i realy wish someone would delete this stupid bot user lewish95!