如何解决"FATAL CONFIG FILE ERROR"?



我已经成功构建了Docker映像,但是当我尝试登录图像时,我将面临问题。我正在用ubuntu构建图像,作为node-10.15.3,mongo-latest和redis-4.0.1。

dockerfile:

FROM ubuntu:14.04
RUN apt-get update
RUN apt-get install -y curl
RUN curl --silent --location https://deb.nodesource.com/setup_4.x | sudo bash -
RUN apt-get install --yes nodejs
RUN apt-get install --yes build-essential
COPY . /src
RUN cd /src
RUN npm install -g npm
#RUN npm install
EXPOSE 8080
RUN apt-get update && apt-get install -y redis-server
EXPOSE 6379
RUN apt-get update
RUN 
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 && 
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' > /etc/apt/sources.list.d/mongodb.list && 
apt-get update && 
apt-get install -y mongodb-org && 
rm -rf /var/lib/apt/lists/*
VOLUME ["/data/db"]
WORKDIR /data
EXPOSE 27017
EXPOSE 28017
ADD run.sh /run.sh
RUN chmod +x /run.sh
ENTRYPOINT ["/usr/bin/redis-server"]
#CMD ["node", "index.js"]
CMD ["/run.sh"]

run.sh文件:

nodaemon=true
command=node index.js
command=mongod

成功构建此Dockerfile后,当我尝试登录图像时,我将获得以下输出: *致命配置文件错误 * 读取配置文件,第3行

'命令= node index.js' 不良指令或错误的参数

我认为删除 ENTRYPOINT并写下您的运行。SH脚本的最佳方法:

#!/bin/bash
cd /data
/usr/bin/redis-server &
mongod &
node index.js

由于在Windows上工作,这里有一个完整的示例:

FROM ubuntu:14.04
RUN apt-get update
RUN apt-get install -y curl
RUN curl --silent --location https://deb.nodesource.com/setup_4.x | sudo bash -
RUN apt-get install --yes nodejs
RUN apt-get install --yes build-essential
COPY . /src
RUN cd /src
RUN npm install -g npm
#RUN npm install
EXPOSE 8080
RUN apt-get update && apt-get install -y redis-server
EXPOSE 6379
RUN apt-get update
RUN 
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 && 
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' > /etc/apt/sources.list.d/mongodb.list && 
apt-get update && 
apt-get install -y mongodb-org && 
rm -rf /var/lib/apt/lists/*
VOLUME ["/data/db"]
WORKDIR /data
EXPOSE 27017
EXPOSE 28017
ADD run.sh /run.sh
RUN chmod +x /run.sh
RUN apt-get update && apt-get install -y dos2unix && dos2unix /run.sh
CMD ["/run.sh"]

无论如何,在container

中启动多个服务是一个坏主意

这是正确的工作代码:Dockerfile:

# Pull base image.
FROM ubuntu:14.04
# Install Node.js
RUN apt-get update
RUN apt-get install -y curl
RUN curl --silent --location https://deb.nodesource.com/setup_10.x | bash -
RUN apt-get install --yes nodejs
RUN apt-get install --yes build-essential
# Bundle angular app source
# Trouble with COPY http://stackoverflow.com/a/30405787/2926832
COPY . /src
# Install app dependencies
RUN cd /src
RUN npm install -g npm
#RUN npm install
# Binds to port 8080
EXPOSE 8080
# Installing redis server
RUN apt-get update && apt-get install -y redis-server
EXPOSE 6379
# Update the repository sources list
RUN apt-get update
# Install MongoDB.
RUN 
    apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 && 
    echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' > /etc/apt/sources.list.d/mongodb.list && 
    apt-get update && 
    apt-get install -y mongodb-org && 
    rm -rf /var/lib/apt/lists/* && 
    cd / 
COPY index.js .
# Define mountable directories.
VOLUME ["/data/db"]
# Define working directory.
WORKDIR /data
# Define default command.
#CMD ["mongod"]
# Expose ports.
#   - 27017: process
#   - 28017: http
EXPOSE 27017
EXPOSE 28017
ADD run.sh /run.sh
RUN chmod +x /run.sh
#  Defines your runtime(define default command)
# These commands unlike RUN (they are carried out in the construction of the container) are run when the container
#ENTRYPOINT  ["/usr/bin/redis-server"]
#CMD ["node", "index.js"]
RUN apt-get update && apt-get install -y dos2unix && dos2unix /run.sh
CMD ["/run.sh"]

run.sh文件中的代码:

#!/bin/bash
cd /data
/usr/bin/redis-server &
mongod &
node /index.js

index.js文件中的代码:

console.log("helllllllooooo");

最新更新