In my case , I have installed ssmtp package on my Unix based host . Because of some reason , the best way in my situation is using ssmtp binary(under /usr/sbin) on my host to send mail (html file) in my APP container .
I attemp to mount the host directory /usr/bin into container:
docker run -v /usr/sbin:/host_sbin --name=myapp -ti -p 889:80 -p 890:5432 myimage
and try to execute ssmtp , here are some awkward tries and their results :
In my APP container and under /host_sbin
ssmtp ---> bash: ssmtp: command not found
./ssmtp ---> bash: ./ssmtp: No such file or directory
So it seems that things are not simple as I think . Could anyone have done something like this share the solution with me ? And I'd appreciate if someone can explain me why that not work .
If you are running more than one container, you can let your containers communicate with each other by attaching them to the same network. Docker creates virtual networks which let your containers talk to each other. In a network, a container has an IP address, and optionally a hostname.
To mount a data volume to a container add the --mount flag to the docker run command. It adds the volume to the specified container, where it stores the data produced inside the virtual environment. Replace [path_in_container] with the path where you want to place the data volume in the container.
Simply mounting the binary into your container does not work as the ssmtp
binary is probably not statically linked. Instead it is linked dynamically to a set of shared libraries that are present in your host system, but not in your container. You can verify this using the ldd
command, whilch will print all libraries that the ssmtp
binary is linked against:
> ldd /usr/sbin/ssmtp
If you wanted to use your host ssmtp
binary, you would also have to mount all required shared libraries into your container (and adjust the library path and so on; I'd recommend not to).
Here's my suggestion: The important bit is probably not the ssmtp
binary, but SSMTP's configuration files (depending on your distribution, but typically found in /etc/ssmtp
). I'd suggest...
ssmtp
inside your container using the image's native package manager. Do not mount the binary from the host into the container.-v /etc/ssmtp:/etc/ssmtp
flag on container creation)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With