I'm trying to run apache in a container and I need to set the tomcat server in a variable since tomcat container runs in a different namespace.
I've set the variable like this but it doesn't work. I've ensured that the variable is present by echoing it in the container and I can ping the host. Documentation says that we can set environment.
I'm not sure why it isn't working...
/etc/httpd/conf.d/workers.properties
worker.ajp13.port=8009
worker.ajp13.host="${TOMCAT_SERVER}"
worker.ajp13.type=ajp13
worker.ajp13.reply_timeout=15000
Figured it out. Had to use parentheses instead of curly braces. Found a example from this site.
worker.ajp12.host=$(TOMCAT_SERVER)
worker.ajp13.type=ajp13
worker.ajp13.reply_timeout=15000
Now I can pass the variable to docker run command like this..
docker run -e TOMCAT_SERVER=tomcat001 --name httpd -p 80:80 -d httpd:0.0.12
Related
Can anyone help with the next issue:
In My application (Asp Net Core 3.1) I have the next connection string
I should create some containers, which have different connection strings but the same image.
I wrote next docker run command (windows server) :
docker run --rm --name admin -it -d -p 8080:8080 qulix/admin -e "ConnectionString:MSSQL"="Server=<IP adress>;Database=BasketballDb;User Id=user;Password=123456;Trust_connection=false"
and connection string didn't change. I don't understand why but I start to read about environment variables but I don't correctly understand how it should help me.
Update
If I change a location it read it as the image name and get the next error
C:\Program Files\Docker\Docker\resources\bin\docker.exe: invalid reference format: repository name must be lowercase.
Anything passes after image name in docker run command it considers as a parameter to entrypoint.
so try to rearrange the docker run command.
docker run --rm -e "ConnectionString:MSSQL\"=\"Server=<IP adress>;Database=BasketballDb;User Id=user;Password=123456;Trust_connection=false" qulix/admin
Also I am not sure your code part, you can look into this
asp.net core override connection strings via ENV variables
app-secrets aspnetcore-3.1
As consuming environment variable is something that depends on the codebase or framework.
My solution was (in windows docker server) next line:
docker run --rm --name stat -it -d -p 8090:8080 -e ConnectionStrings:MSSQL="Server=<IP Adress>;Database=Basketball_stat;User Id=user;Password=123456;" admin
where
ConnectionStrings:MSSQL should be without any quotes
"Server=<IP Adress>;Database=Basketball_stat;User Id=user;Password=123456;" with quotes(double or single)
admin is the name of repository
I have a docker container with a environment variable that I want to change on restart time. I have read about the -e option that can be used for that in docker run command (described for instance here).
I have tried to use it with restart:
sudo docker restart 1db2df40d98c -e FOOBAR_VERSION='v1'
However, I get this error:
unknown shorthand flag: 'e' in -e
See 'docker restart --help'.
I have also read about re-building the container with the new environment variable value. However, I'd like to avoid so overhelming alterantive. I just want to restart the container, but with a different environment variable value at starting time.
Any hint/reference/help regarding this problem is really welcome, please.
EDIT: I have also tried doing the restart in two steps, I mean:
sudo docker stop 1db2df40d98c
sudo docker start 1db2df40d98c -e FOOBAR_VERSION='v1'
But the result is the same.
I want to run a command like:
docker run --network host ...
But I can't actually change my docker run command. Is there another way to have Docker do essentially the same thing, like reading from a config file or environment variables?
For example, I know I can set a HOSTNAME env in my Dockerfile, which accomplishes the same thing as
docker run --hostname my_hostname
Is there a way to do this more generally with other arguments?
Thanks.
While working behind the corporate proxies..
Why can't docker export the proxy specific value from environment variables
(http_proxy, https_proxy,...).
Usually you get timeout issue while pulling the image, even if the proxy url is mentioned in environment vairable.
I have to set the value (hard-code the same value again) in or by creating the config files in /etc/systemd/system/docker.service.d folder.
If we change the proxy url, we have to make changes in different place. Or is there any way to refer the value from environment variable ?
I have tried the docker run -e env_proxy_variable=proxy_url but got the same timeout issue.
Consider using the below instead:
export HTTP_PROXY=http://xxx:port/
export HTTPS_PROXY=http://xxx:port/
export FTP_PROXY=http://xxx:port/
You can hardcode these variables in the /etc/default/docker file so that they are exported whenever docker is started.
You can check if the environment variable has been exported by typing $(name_of_var). For eg, after running
docker run --env HTTP_PROXY="123.45.21.32" -it ubuntu_latest /bin/bash
type
echo $HTTP_PROXY
It is likely that your DNS server isn't configured. Try
cat /etc/resolv.conf
if you see something like:
nameserver:8.8.8.8
then it's likely that the DNS server is inaccessible behind firewalls. You can pass dns server address along with docker run command like so:
docker run --env HTTP_PROXY="123.45.21.32" --dns=172.10.18.0 -it ubuntu_latest /bin/bash
I am referring this site to link containers.
When two containers are linked, Docker will set some environment variables in the target container to enable programmatic discovery of information related to the source container.
This is the line specified in the documentaion. But when i see /etc/hosts i can see entries for both container. But when i run env command, i don't see any port mappings specified in that docker site.
Works fine for me:
$ docker run -d --name redis1 redis
0b869d9f5a43e24976beec6c292839ea2c67983012e50893f0b557cd8bc0c3b4
$ docker run --link redis1:redis1 debian env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=c23a30b8618f
REDIS1_PORT=tcp://172.17.0.3:6379
REDIS1_PORT_6379_TCP=tcp://172.17.0.3:6379
REDIS1_PORT_6379_TCP_ADDR=172.17.0.3
REDIS1_PORT_6379_TCP_PORT=6379
REDIS1_PORT_6379_TCP_PROTO=tcp
REDIS1_NAME=/berserk_nobel/redis1
REDIS1_ENV_REDIS_VERSION=2.8.19
REDIS1_ENV_REDIS_DOWNLOAD_URL=http://download.redis.io/releases/redis-2.8.19.tar.gz
REDIS1_ENV_REDIS_DOWNLOAD_SHA1=3e362f4770ac2fdbdce58a5aa951c1967e0facc8
HOME=/root
If you're still having trouble, you need to provide a way we can recreate your problem.