I'm very new to Docker and CI's so please be don't grill me:)
I'm on Linode and I would like to to run the frontend(react) and backend(python) on the same server. Both will be on separate ports, unless you tell me that this is a wrong approach.
Now, I'm running Jenkins on port 8081
and have two individual jobs:
Backend Jenkins:
IMAGE = "my_docker_flask:latest"
image = docker.build("${IMAGE}");
def container = image.run('-p 5000:5000')
def contport = container.port(5000)
Backend Dockerfile (flask):
FROM python:2.7
WORKDIR app
COPY . .
RUN pip install -r requirements.txt
ENTRYPOINT ["python"]
CMD ["app.py"]
Frontend Jenkins:
IMAGE = "reactapp"
image = docker.build("${IMAGE}")
def container = image.run('-p 6000:6000')
def contport = container.port(6000)
Frontend Dockerfile:
FROM nginx
COPY build /var/www
The backend works fine when I open my Linode's IP with port 5000
but the 6000
does not work. I even tried with 3333
but that does not work either and.
Here's my docker ps -a
:
reactapp "nginx -g 'daemon of…" 41 seconds ago Up 40 seconds 80/tcp, 0.0.0.0:6000->6000/tcp
reactapp "nginx -g 'daemon of…" 2 days ago Up 2 days 80/tcp, 0.0.0.0:3333->3333/tcp
my_docker_flask:latest "python app.py" 2 days ago Up 2 days 0.0.0.0:5000->5000/tcp
Can please someone help me?
How can I run multiple apps on different ports using the same IP?
EDIT
I have fixed it but changing to the below:
COPY build /usr/share/nginx/html
and
def container = image.run('-p 5000:80')
80/tcp, 0.0.0.0:6000->6000/tcp
Looking at this carefully, we can know that your reactapp
service is being served at port 80
within the container. But you are trying to map the port 6000
in the container to port 6000
outside. Certainly, you will not be able to access a service where it is not being served at all.
Also, the reason behind This site can't be reached - ERR_UNSAFE_PORT
is because you are using the port 6000
which is restricted by the Chrome browser.
Solution:
reactapp
service, as we don't want the other instance to block the port.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.