I running FastAPI docker image and getting timeouts. The default timeout is 60 seconds. Any idea what will be the simplest way to increase the timeout?
Timeout can be modified by changing the environment variable TIMEOUT
You can either set the variable in the command when you build the container or you can add it to your docker compose file.
Here you have more information about it.
Timeout variable
Related
I have a docker compose yml file with a few containers defined:
database
web-service
I have 'depends_on' defined in 'web-service' to start after 'database'. Both containers are defined with 'restart always'.
I've been googling and cannot find clear info on container startup order on system reboots. Does the docker daemon read the docker-compose yml file and start the database and then web-service? Or how does it work?
If you want to start the containers on system startup you have to setup a some kind of "scheduled" job using e.g. Linux's CRON daemon.
Docker daemon itself is not responsible for waking-up containers, restart entry in compose file refers to e.g. restarting on crash of app in the container, after ending a job (which terminates terminal) and so on.
Please find the restarts explanation of docker docs https://docs.docker.com/config/containers/start-containers-automatically/#restart-policy-details
containers are started according to depends_on contraints.
on reboot too.
but you should not rely on it too much.
you can just let your web service crash when he has no acces to the db. docker will restart it automatically and it will retry. (it's cheap)
if you want to deal with it more safely/precisely, you can also wait for the port to be accessible using a script like this one.
https://github.com/vishnubob/wait-for-it
docker explains it in his documentation : https://docs.docker.com/compose/startup-order/
that way you garanty way more than depends_on. because depends only ganranty order, not that to service is ready or even working.
I am deploying a FastAPI application which is dockerized. I deployed that dockerized file on AWS Elastic Beanstalk. But for some functions, the process is taking more than 60 seconds, and it times out. I need the timeout to be at least 300 seconds. How can I accomplish this?
I tried CMD and ENTRYPOINT in the Dockerfile, but didn't work. I tried using gunicorn config file with timeout settings but didn't work. I also tried modifying dockerrun.aws.json with the code '"timeout":300', didn't work as well. What is the best solution to this?
Thanks.
Lets say we have a microservice which runs in docker container.
Now to bring up this service, it uses cache which is mounted on the host volume which gets shared by all
the other docker images for same microservice. And to build this cache in app it takes 10 mins and then application gets ready to serve the request.
But this scenario gets failed when we will scale up and scale down,
Lets say I am scaling up container will be available but its still not fully up because we need to wait
to build the cache.
How you suggest to handle this scenario.
And at the font of this docker services we are planning to bring Nginx to load balance the request.
Thanks in Advance
If I understand you right, you want to know when your container is fully up and running. One option could be the Health Check. This feature was added in Docker 1.12.
Description (from Docker Docs):
The health check will first run interval seconds after the container is started, and then again interval seconds after each previous check completes.
If a single run of the check takes longer than timeout seconds then the check is considered to have failed.
It takes retries consecutive failures of the health check for the container to be considered unhealthy.
There you can specify to run any command to check your server status.
The Health of your container can be checked by using the inspect-command
docker inspect --format='{{json .State.Health}}' <container-id>
This feature adds also the "(healthy)"-information to the status in docker ps.
I have 10 container in docker compose.
I want 9 containers to start working when i up the docker compose and allow docker-compose to run the 10th container after 1 hour of time.
Currently its running all containers at once.
How i can achieve this ?
Docker Compose doesn’t directly have this functionality. (Kubernetes doesn’t either, though it does have the ability to run a short-lived container at a specified time of day.)
Probably the best workaround to the problem as you’ve stated it is to use a tool like at(1) to run an additional container at a later time
at +1h docker run ...
My experience has generally been that it can get a little messy to depend on starting and stopping Docker containers for workflow management. You may be better off starting a pool of workers against some job queue system like RabbitMQ and injecting a job after an hour, or using a language-native scheduled-task library in your application, and just always start every container every time.
I'm using the Payara image in Dockerhub. If I want to change a configuration parameter in Payara that requires a restart (via asadmin restart domain) the container stops.
How can you make configuration changes like the above without the container stopping ?
I've raised an issue for this:
https://github.com/payara/docker-payaraserver-full/issues/45
In Docker, containers should be preconfigured in the DockerFile and when you change the configuration, you should rebuild your docker container and restart it. You shouldn't expect that you change the config dynamically without a restart, that's not how most of the Docker containers work.
You still can do what you want with the current Payara docker image if you overwrite the ENTRYPOINT using bin/asadmin start-domain instead of the startInForeground.sh script. This will execute a launcher Java process, which will watch over the server process and restart it when needed. The startInForeground.sh script is used by default to optimize running the server in the container.