FROM openjdk:8-jdk-alpine
EXPOSE 8080
ARG JAR_FILE=target/demo-0.0.1-SNAPSHOT.jar
ADD ${JAR_FILE} demo.jar
ENTRYPOINT ["java","-jar","/demo.jar"]
我能成功地建立docker映像
下面是我的docker-compose
# Docker Compose file Reference (https://docs.docker.com/compose/compose-file/)
version: '3.7'
# Define services
services:
# App backend service
app-server:
# Configuration for building the docker image for the backend service
build:
context: . # Use an image built from the specified dockerfile in the `polling-app-server` directory.
dockerfile: ./Dockerfile
container_name: empserver
ports:
- "3000:3000" # Forward the exposed port 8080 on the container to port 8080 on the host machine
restart: always
depends_on:
- db # This service depends on mysql. Start that first.
environment: # Pass environment variables to the service
SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/employee_entries?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: root
# Database Service (Mysql)
db:
image: mysql:5.7
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: employee_entries
MYSQL_HOST: 127.0.0.1
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_ROOT_PASSWORD: root
MYSQL_ROOT_USER: root
现在我做到了
Starting demo_db_1 ... error
ERROR: for demo_db_1 Cannot start service db: failed to create endpoint demo_db_1 on network demo_default: hnsCall failed in Win32: The process cannot access the file because it is being used by another process. (0x20)
ERROR: for db Cannot start service db: failed to create endpoint demo_db_1 on network demo_default: hnsCall failed in Win32: The process cannot access the file because it is being used by another process. (0x20)
ERROR: Encountered errors while bringing up the project.
当服务停止时,它给出了以下错误
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
empserver | at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_212]
empserver | at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_212]
empserver | at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_212]
empserver | at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_212]
empserver | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
empserver | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
empserver | at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
empserver | at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
empserver | at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:91) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
empserver | at com.mysql.cj.NativeSession.connect(NativeSession.java:144) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
empserver | at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:956) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
empserver | at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
empserver | ... 56 common frames omitted
empserver | Caused by: java.net.ConnectException: Connection refused (Connection refused)
empserver | at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_212]
empserver | at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_212]
empserver | at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_212]
empserver | at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_212]
empserver | at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_212]
empserver | at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_212]
empserver | at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
empserver | at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65) ~[mysql-connector-java-8.0.19.jar!/:8.0.19]
empserver | ... 59 common frames omitted
似乎应用程序在数据库服务器可用之前就已启动。您需要等待db可用,然后启动应用程序服务器。有一个实用程序可以用来进行这种同步。[https://github.com/ufoscout/docker-compose-wait]
修改dockerfile以将此脚本包含在其中
FROM openjdk:8-jdk-alpine
EXPOSE 8080
ARG JAR_FILE=target/demo-0.0.1-SNAPSHOT.jar
ADD ${JAR_FILE} demo.jar
## Add the wait script to the image
ADD https://github.com/ufoscout/docker-compose-wait/releases/download/2.7.3/wait /wait
RUN chmod +x /wait
ENTRYPOINT ["java","-jar","/demo.jar"]
这样,wait脚本就成为了映像的一部分,可以按如下所示使用:请注意添加到app-server部分的命令和环境变量。我目前正在使用这个精确的设置,其中我有4个服务和2个数据库运行在docker compose中,所有服务都需要等待两个数据库可用,4个服务中的2个需要等待另一个服务可用。
# Docker Compose file Reference (https://docs.docker.com/compose/compose-file/)
version: '3.7'
# Define services
services:
# App backend service
app-server:
# Configuration for building the docker image for the backend service
build:
context: . # Use an image built from the specified dockerfile in the `polling-app-server` directory.
dockerfile: ./Dockerfile
command: sh -c "/wait && java -jar /demo.jar"
container_name: empserver
ports:
- "3000:3000" # Forward the exposed port 8080 on the container to port 8080 on the host machine
restart: always
depends_on:
- db # This service depends on mysql. Start that first.
environment: # Pass environment variables to the service
SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/employee_entries?useSSL=false&serverTimezone=UTC&useLegacyDatetimeCode=false
SPRING_DATASOURCE_USERNAME: root
SPRING_DATASOURCE_PASSWORD: root
WAIT_HOSTS: db:3306
# Database Service (Mysql)
db:
image: mysql:5.7
ports:
- "3306:3306"
environment:
MYSQL_DATABASE: employee_entries
MYSQL_HOST: 127.0.0.1
MYSQL_USER: root
MYSQL_PASSWORD: root
MYSQL_ROOT_PASSWORD: root
MYSQL_ROOT_USER: root
network:
my-network:
我正在使用mime类型为“video/avc”的对预览数据进行编码,并将编码数据(仅视频,无音频)传递给。muxer似乎运行良好,并创建了一个大小合理的输出文件(即,记录的时间越长,输出文件越大)。但是,当我试图停止多路复用器时,会出现“无法停止多路复用器”错误: 在失败的停止之前,有一些可疑的MPEG4Writer日志消息: 有什么线索导致这一切吗?不确定你还需要什么信息。
我已经在我的Win 10上安装了XAMPP 7.2.10,Apache和MySQL等其他服务运行良好。但是Tomcat服务没有启动,并且会抛出一个错误:“Tomcat Started/Stopded with error,返回代码:1,确保您安装了JavaJDK或JRE,并且所需的端口是免费的,检查“/xampp/tomcat/logs”文件夹以获取更多信息”XAMPP Tomcat错误图像 我在
本文向大家介绍解决“无法启动mysql服务 错误1069”的方法,包括了解决“无法启动mysql服务 错误1069”的方法的使用技巧和注意事项,需要的朋友参考一下 今天还在路上的时候,同事就发来消息,说网站后台无法访问了,那个急啊! 赶到公司,登陆服务器,正常,还好,看来不是服务器自身的问题,看错误提示,应该是mysql的问题了。 到服务选项里已查看,果然,未启动状态,启动MYSQL的时候提示错误
问题内容: 我们有一个自定义服务,我们将其与应用程序一起安装。唯一的问题是,安装后它将无法启动,从而产生上述错误。我试图诊断出问题所在,但似乎找不到有关退出原因的有用信息。我已经在非“ R2” 2008服务器上尝试了相同的服务,并且手动运行正常。 服务使用批处理文件运行的简单Java文件。恶魔服务。 有没有人有解决此类问题的经验,线索很少? 问题答案: 去: 注册表-> HKEY_LOCAL_M
启动jboss服务器时,出现错误,无法启动服务jboss.deployment.unit.“jbpm console.war”。但是当我使用start.demo运行jbpm6演示时,它工作得很好。
通常,我会遇到这样的错误:(本地计算机上的“服务名称”服务启动然后停止。如果其他服务或程序未使用某些服务,则会自动停止)当我的代码出现错误时,例如不存在的驱动器路径等。windows服务将不会启动。 我有一个Windows服务,如果文件夹/文件达到大小限制,它可以备份到某个位置。详细信息都由Windows服务在启动时读取的XML配置提供。我有一个单独的Windows表单,其中有一个按钮,它完全执行