Im new at docker. I am making a java sockets music server and i have 2 files. Client.java and Server.java. Both are in separate containers. To mention, i run both services in command line
Docker files
FROM java:8
COPY Server.java /
RUN javac Server.java
EXPOSE 25000
ENTRYPOINT ["java"]
CMD ["Server"]
FROM java:8
COPY Client.java /
RUN javac Client.java
EXPOSE 25000
ENTRYPOINT ["java"]
CMD ["Client"]
i create also a network for these two to communicate.
docker network create client_server_network
and i run the images as follows:
docker run --env SERVER_HOST_ENV=server --network-alias server --network client_server_network -it server
docker run --network client_server_network -it clientimage
Now i want to create a docker compose file with those two Dockerfiles and the network. This is what i have done so far:
version:'3'
services:
client:
image: java:8
ports:
-25000:25000
network:
default:
name: client_server_network
server:
image: java:8
ports:
-25000:25000
environment:
-SERVER_HOST_ENV=server
network:
My question is how to add the common network in both services. Also is the way i write my docker compose file correct?
question from:
https://stackoverflow.com/questions/65641622/docker-files-to-docker-compose 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…