[英]Docker startup script cannot be found
I am using Docker for Windows 10 to start up a eureka and configuration server. 我正在使用Windows 10的Docker来启动eureka和配置服务器。 I'm trying to add startup script to ensure eureka has fully started before starting the config server.
我正在尝试添加启动脚本,以确保eureka在启动配置服务器之前已完全启动。 The following files are stored at the root of my project:
以下文件存储在我的项目的根目录中:
Dockerfile - config server Dockerfile-配置服务器
FROM openjdk:8-jdk-alpine
RUN apk update && apk upgrade && apk add netcat-openbsd && apk add curl
RUN mkdir -p /usr/local/configserver
ADD ./target/config-server-0.0.1-SNAPSHOT.jar /usr/local/configserver/
ADD run.sh run.sh
RUN chmod +x run.sh
CMD ./run.sh
run.sh 运行
#!/bin/sh
echo "********************************************************"
echo "Waiting for the eureka server to start on port $EUREKASERVER_PORT"
echo "********************************************************"
while ! `nc -z eurekaserver $EUREKASERVER_PORT`; do sleep 3; done
echo ">>>>>>>>>>>> Eureka Server has started"
echo "********************************************************"
echo "Starting Configuration Server
echo "********************************************************"
java -jar /usr/local/configserver/config-server-0.0.1-SNAPSHOT.jar
Using the following docker-compose: 使用以下docker-compose:
docker-compose.yml docker-compose.yml
version: '2.2'
services:
eurekaserver:
image: eureka-naming-server
ports:
- "8761:8761"
configserver:
image: config-server
ports:
- "10000:10000"
environment:
EUREKASERVER_PORT: 8761
EUREKASERVER_URI: "http://eurekaserver:8761/eureka/"
I get the following output: 我得到以下输出:
C:\docker\prj> docker-compose -f docker-compose.yml up
Creating eureka-naming-server_configserver_1 ... done
Creating eureka-naming-server_eurekaserver_1 ... done
Attaching to eureka-naming-server_configserver_1, eureka-naming-server_eurekaserver_1
configserver_1 | /bin/sh: ./run.sh: not found
Any ideas as to why run.sh cannot be found? 为什么找不到run.sh的任何想法? Thanks
谢谢
My dear i think your problem is with this : 亲爱的,我认为您的问题在于:
ADD run.sh run.sh
添加run.sh run.sh
you are trying to copy run.sh from your host machine to your docker image, ensure that run.sh exists in your project directory which is in your case it should be beside Dockerfile. 您尝试将run.sh从主机复制到docker映像中,请确保run.sh存在于您的项目目录中,在您的情况下,该目录应位于Dockerfile旁边。
I've a running example like your case in my git repo : https://github.com/iabughosh/microservices , develop branch, it is not merged to master yet. 我在git repo中有一个正在运行的示例,如您的情况: https : //github.com/iabughosh/microservices,develop分支,它尚未合并到master。
you don't specify the dockerfile in your docker-compose file. 您无需在docker-compose文件中指定dockerfile。 You need to remove the
image: xyz
and instead write build: .
您需要删除
image: xyz
然后编写build: .
image: xyz
(assuming the dockerfile is on the same location as the docker-compose.yml) (假设dockerfile与docker-compose.yml位于同一位置)
As it is, your dockerfile is never even built 实际上,您的dockerfile甚至都不会构建
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.