Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux 如何解决“致命配置文件错误”?_Linux_Docker_Dockerfile - Fatal编程技术网

Linux 如何解决“致命配置文件错误”?

Linux 如何解决“致命配置文件错误”?,linux,docker,dockerfile,Linux,Docker,Dockerfile,我已经成功构建了docker映像,但是当我尝试登录到映像时,我面临一个问题。我正在以ubuntu为基础,以node-10.15.3、mongo最新版本和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

我已经成功构建了docker映像,但是当我尝试登录到映像时,我面临一个问题。我正在以ubuntu为基础,以node-10.15.3、mongo最新版本和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"]
# 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文件:

nodaemon=true

command=node index.js

command=mongod
#!/bin/bash
cd /data
/usr/bin/redis-server &
mongod &
node /index.js
成功构建此Dockerfile后,当我尝试登录到映像时,我得到以下输出: *致命的配置文件错误* 在第3行读取配置文件

'command=node index.js' 指令错误或参数数目错误


我认为删除ENTRYPOINT并编写run.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"]

无论如何,在一个容器中启动多个服务不是一个好主意这是正确的工作代码: 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"]
# 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文件中的代码:

nodaemon=true

command=node index.js

command=mongod
#!/bin/bash
cd /data
/usr/bin/redis-server &
mongod &
node /index.js
index.js文件中的代码:

console.log("helllllllooooo");

谢谢镜像已成功构建,但当我使用docker run-it登录到镜像时,我得到以下错误:standard_init_linux.go:207:exec用户进程导致exec格式错误我得到此错误,当我登录到我的docker image:standard_init_linux.go:207:exec用户进程没有导致这样的文件或目录时,我运行了该命令并得到以下错误:步骤21/22:RUN apt get install-y dos2unix&&dos2unix RUN.sh-->在f85ae66196d1中运行读取包列表。。。正在构建依赖关系树。。。正在读取状态信息。。。E:找不到程序包dos2unix命令“/bin/sh-c apt get install-y dos2unix&&dos2unix run.sh”返回一个非零代码:100获取以下错误:选择以前未选择的程序包dos2unix。正在读取数据库。。。20824当前安装的文件和目录。正在准备解包…/dos2unix_6.0.4-1_amd64.deb。。。正在解包dos2unix 6.0.4-1。。。正在设置dos2unix 6.0.4-1。。。dos2unix:run.sh:没有这样的文件或目录dos2unix:跳过run.sh,不是常规文件。命令'/bin/sh-c apt get update&&apt get install-y dos2unix&&dos2unix run.sh'返回一个非零代码:2但是,当我尝试登录到映像时,我得到如下错误:2019-06-27T14:23:28.152+0000[initandlisten]分配器:tcmalloc 2019-06-27T14:23:28.152+0000[initandlisten]选项:{}module.js:327 throw err;^错误:在Function.module中找不到模块“/data/index.js”。_resolveFileNamemodule.js:325:15在Function.module.runMain module.js:276:25在Function.module.runMain module.js:441:10在启动节点。js:140:18在节点。js:1043:3