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
Related
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'm trying to run a bokeh server within a Docker container but bokeh doesn't allow me to enter commands while the server is running. Is there a way to run the server detached so that I can enter other commands while the page is up? I'm using a (slightly modified) ubuntu image with python3 for this container.
If anyone happens to also know why I wouldn't be able to access the page from my host machine after exposing the ports that'd be even better-that's the larger issue I'm trying to solve.
You can use this line:
bokeh serve --show --allow-websocket-origin=localhost:5006 file_name.py
Put the following at the end of the dockerfile to run the command above and be able to access the app your trying to host:
CMD ["bokeh","serve","--show","--allow-websocket-origin=localhost:5006","file_name.py"]
So I'm trying to run this project using docker.
I followed the standard docker protocol:
docker build -t orange .
docker run -p 8080:8080 orange
I used the following command to check that the docker image was indeed created.
docker image ls
However, after running these commands, there is still no site running on localhost:8080. Any tips on troubleshooting this?
EDIT: After using the right port, I'm getting a directory listing instead of an actual site. Directory listing
By looking at the repository, it seems that the exposed port is 9999 and not 8080. Also, it looks like you can use docker-compose, that is, you can run
docker-compose up --build
to spin up the server. You should then be able to reach it at localhost:9999
I have a remote machine at my workplace, when we developers run server/ or docker containers. everything was working fine but a while back somethign went wrong.
if I run the python flask app
from app import app
app.run(host='0.0.0.0', port=5050)
i get message
* Running on http://0.0.0.0:5050/
and I am able to access the above from my local machine using the remote server machine ip:5050 but if I run docker container docker run -itd <conta_image_name> -p 80:90 --add-host=localdomain.com:machine_ip_address i get error message saying IPv4 forwarding is disabled. Networking will not work.
Now this issue is in production so I really need someone to throw up some light, what might be wrong or let me know what more info I need to put.
I have fixed this issue myself following this: https://success.docker.com/article/ipv4-forwarding
Another solution is..
Try adding -net=host along with docker run command
https://medium.com/#gchandra/docker-ipv4-forwarding-is-disabled-8499ce59231e
I try to run django on a docker container using sqllite as the db and the django dev server. So far I was able to launch locally the django server:
python .\manage.py runserver
I can build the docker image using Dockerfile:
docker build . -t pythocker
But when I run the image with docker run -p 8000:8000 pythocker no output is shown and the machine is not reachable, I have to kill the running container.
If I add the -it flag on the docker run command then the server is running and I can go to http://192.168.99.100:8000 and display the django welcome page. Why is this flag mandatory here?
Docker logs on the container gives nothing. I also tried to add custom logging inside the manage.py but it's not diplayed in the console or in the docker logs.
I am using the Docker Windows toolbox as I have only a windows home computer.