I am trying to dockerize two applications, one being streamlit, the other being fastapi, I have built the individual docker images for them, and now trying to run them at the same time so they communicate using docker-compose.
I have written the code but get an error when i run docker-compose up --build, that says
ERROR: Service "backend" uses an undefined network "AIservice"
because of this part of the code
networks:
AIservice:
aliases:
- backend.docker
how do i fix this error
Related
While running sagemaker in local mode.
I am experimenting with an inference endpoint in local mode using docker container. But as soon as my model.tar.gz file exceeds a certain size i.e. around 200 mb, the deployment fails and returns the error:
RuntimeError: Giving up, endpoint: didn't launch correctly
When I deploy it on a sagemaker instance, it works fine.
Do you know if there is something I could do, perhaps some docker setting I could change to make sure that the local deployment also works with the larger model.tar.gz?
Instead of using SageMaker SDK Local Mode, you can also run vanilla docker commands yourself to imitate the hosted environment:
Such as:
Start "local endpoint"
image=$1
docker run -v $(pwd)/test_dir:/opt/ml -p 8080:8080 --rm ${image} serve
Invoke "local endpoint"
payload=$1
content=${2:-text/csv}
curl --data-binary #${payload} -H "Content-Type: ${content}" -v http://localhost:8080/invocations
https://github.com/aws/amazon-sagemaker-examples/tree/main/advanced_functionality/scikit_bring_your_own/container/local_test
I am running succesfully a django app that is hosted inside a docker container. I change something on my code on purpose in order for my code to break. What I need is somehow to see the log of the running code as if I was running this locally on my computer. For example I forgot to import a library and when I run this locally I get a message on the terminal like "ModuleNotFoundError: No module named 'somemodule'". But when i run the same code from inside the container I get no log, just the container fails to start.
My question is: How can I get a log for my script from inside the container, so I can debug my code?
So, what I wanted to do was to somehow debug/run my own python code that was inside a container in order to see the log of my code.
I managed to do it using VSC and Remote SSH and Remote - Containers extensions.
Remote SSH
Remote - Containers
If the containers are hosted locally on your PC, you dont need the Remote - SSH extension
Context
I am running Apache Airflow, and trying to run a sample Docker container using Airflow's DockerOperator. I am testing using docker-compose and deploying to Kubernetes (EKS). Whenever I run my task, I am receiving the Error: ERROR - Error while fetching server API version. The erros happens both on docker-compose as well as EKS (kubernetes).
I guess your Airflow Docker container is trying to launch a worker on the same Docker machine where it is running. To do so, you need to give Airflow's container special permissions and, as you said, acces to the Docker socket. This is called Docker In Docker (DIND). There are more than one way to do it. In this tutorial there are 3 different ways explained. It also depends on where those containers are run: Kubernetes, Docker machines, external services (like GitLab or GitHub), etc.
I have a python flask project which is supposed to be a web app for an internal network. It's in a docker image which is started with a docker-compose file.
Sometimes when I run it, the flask server doesn't get messages from the outside world. I figure it has to be a problem with the docker network that docker-compose automatically creates. Whenever this problem occurs I have to restart the box then bring the container back up, and it fixes itself.
Has anyone else seen this?
When I say it doesn't see connections from outside the box I mean HTTP requests never make it to the flask server. I can attempt to go to the URL corresponding to the flask server from a different machine and the flask server sees nothing. However, if I attempt to send an HTTP GET request from inside the box (not inside the container, but on the box the container is running on) the flask server responds.
So this leads me to believe docker-compose is creating a docker network which isn't configured correctly to allow the container to listen to outside requests.
Here's my docker compose file:
version: '3.7'
services:
falcon:
image: "company.com/internal/falcon:0.1"
container_name: falcon
env_file:
- ~/.env
ports:
- "80:80"
volumes:
- ${REPOS}/falcon:/app
command: /conda/bin/falcon start
This hasn't been tested extensively, but it seems to have solved the problem:
version: '3.7'
services:
falcon:
image: "company.com/internal/falcon:0.1"
container_name: falcon
network_mode: bridge # also tried host, I think bridge is right.
Another solution seemed to omit the network_mode above and put this down below:
networks:
default:
external:
name: prod_default
I still don't know why it happened, but both of these solutions seemed to fix it.
I am trying to do
http://containertutorials.com/docker-compose/flask-simple-app.html
I have copied the tutorial verbatim, except I changed
From flask import Flask
to
from flask import Flask
I can built it just fine. I can start it and get the following when I run docker ps from the command line
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
291c8dfe5ddb whatever:latest "python app.py" About a minute ago Up About a minute 0.0.0.0:5000->5000/tcp sick_wozniak
I am building this on OSX
I have tried the following
Looking at this post Deploying a minimal flask app in docker - server connection issues
Running $ python app.py to make sure it works without docker
Creating a django project and a dockerfile for that project. Then build, run and access.
So I am confident that docker is working and flask is working independently of each other, but I cannot get them to work together.
If on Linux, then http://localhost:5000 should work seeing as the container is both running and listening on port 5000.
Otherwise, you would be using Docker Machine, and so you need to get the IP of the docker virtual machine using docker-machine ip. On OSX, for example
$ open http://$(docker-machine ip default):5000