Как решить "FATAL CONFIG FILE ERROR"? - PullRequest
0 голосов
/ 27 июня 2019

Я успешно создал образ 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

'command = node index.js' Неверная директива или неверное количество аргументов

Ответы [ 2 ]

1 голос
/ 27 июня 2019

лучший способ удалить ENTRYPOINT и написать скрипт run.sh следующим образом:

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

, поскольку работает с окнами, вот полный пример:

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

0 голосов
/ 03 июля 2019

Это правильный рабочий код: 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");
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...