# based on JDK mirror
The FROM Java: 8
# to local folders to hang on to the current container
VOLUME/TMP
# copy the file to the container
ADD the boss - bes - system - the manager - controller - 0.0.1 - the SNAPSHOT. Jar app. Jar
# statement needs to be exposed port
EXPOSE 8081
# configuration container startup after execution of command
ENTRYPOINT [" Java ", "- Djava. Security. Or egd=file:/dev/./urandom", "- the jar", "/app. Jar"]
And then execute the following command to build the mirror and start the container
Docker build - t systen - manager.
Docker run - d - name system - service - expose=8081-8081: p. 8081 - e "EUREKA_INSTANCE_IP - ADDRESS=.,,,,," e "SERVER_PORT=8081" system - manager
This is on the container
This is a postman error
{
"Timestamp" : "the 2020-04-11 T13: thou. 239 + 0000",
"Status" : 500,
"Error" : "Internal Server error",
"Message" : "nested exception is org. Apache. Ibatis. Exceptions. PersistenceException: \ n# # # Error querying the database. The Cause: org. Springframework. JDBC. CannotGetJdbcConnectionException: Failed to obtain a JDBC Connection; nested exception is com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure\n\nThe last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.\n### The error may exist in class path resource [mappers/UserMapper.xml]\n### The error may involve com.boss.bes.system.manager.dao.mapper.UserMapper.selectByCode\n### The error occurred while executing a query\n### Cause: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; Nested exception is com.mysql.cj.jdbc.exceptions.Com municationsException: Communications link failure \ n \ nThe last packet sent successfully to the server was 0 milliseconds line. The driver has not received any packets from the server, "
"Path" : "//system/user/findUserByCode"
}
CodePudding user response:
Database run locally jar can be connected, but unable to connect to the database after jar encapsulated into a docker, whether you can check the database can be connected through this mirror mode, can try to give the database configuration a mirror and then through the mirror address and port to connect to the database,CodePudding user response:
The database connection, make sure your database is and whether your container in a network segment