Closed ghkdqhrbals closed 2 years ago
In my desktop,
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 97911f43ff87 react-portfolio-website_client "…" 26 minutes ago Up 8 minutes client 256b592d3a35 react-portfolio-website_nginx "…" 26 minutes ago Up 8 minutes 0.0.0.0:80->80/tcp nginx
And listen ports
gyuminhwangbo@Gyuminui-MacBookPro react-portfolio-website % lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME Kite 727 gyuminhwangbo 24u IPv4 0x9a7e8ab200a061ed 0t0 TCP 192.168.0.36:59859->hkg12s36-in-f14.1e100.net:http (ESTABLISHED) com.docke 1083 gyuminhwangbo 121u IPv6 0x9a7e8ab1ff4b83e5 0t0 TCP *:http (LISTEN)
There are only difference in ports
EC2 0.0.0.0:80->80/tcp, :::80->80/tcp nginx
DESKTOP 0.0.0.0:80->80/tcp nginx
When i run test in nginx(EC2)
ubuntu@ip-172-31-7-36:~/portfolio$ sudo docker port nginx 80/tcp -> 0.0.0.0:80 80/tcp -> :::80
When i run test in nginx(DESKTOP)
gyuminhwangbo@Gyuminui-MacBookPro react-portfolio-website % docker port nginx
80/tcp -> 0.0.0.0:80
What is meaning of 80/tcp -> :::80?
:::80 is ipv6 localhost:80 !!!
In your React project, package.json exists like below.
"scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" },
Here, "start": "react-scripts start" start your React project with 3000 port by default.
Thus, if we want to run server with port 3400, we should also change default port as well as in Dockerfile
FROM node:18-alpine3.16 RUN mkdir /app WORKDIR /app
ENV PATH /app/node_modules/.bin:$PATH
COPY package.json /app/package.json RUN npm install --production
CMD ["/app/start.sh"] << ADDED COPY .env /app/.env << ADDED
CMD ["npm", "start"]
This file makes .env file which has text PORT="3400"
!/bin/sh
set -e
echo "make .env with PORT=$PORT" echo "PORT=$PORT" > .env
ERROR
Docker containers