1

I would like install auditserver on nodejs server , So my auditserver with rpm . it is working fine as a manual steps.

I write a Dockerfile like below.

FROM    centos:centos6

# Enable EPEL for Node.js
RUN rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

# Install Node.js and npm
RUN yum install -y npm

# ADD rpm into container
ADD auditserver-1-1.x86_64.rpm /opt/

RUN mkdir -p /opt/auditserver

RUN cd /opt

RUN rpm -Uvh auditserver-1-1.x86_64.rpm

# cd to auditserver
RUN cd /opt/auditserver

# Install app dependencies
RUN  npm install
# start auditserver
RUN node server

EXPOSE  8080

while building the docker file I see below issue.

root@CloudieBase:/tmp/sky-test# docker build -t sky-test .
Sending build context to Docker daemon  38.4 kB
Step 1 : FROM centos:centos6
 ---> 9c95139afb21
Step 2 : RUN rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
 ---> Using cache
 ---> fd5b1bb647fc
Step 3 : RUN yum install -y npm
 ---> Using cache
 ---> b7c2908fc583
Step 4 : ADD auditserver-1-1.x86_64.rpm /opt/
 ---> 26ace798f98c
Removing intermediate container 5ea6221797f5
Step 5 : RUN mkdir -p /opt/auditserver
 ---> Running in 8f7292364245
 ---> 9b340033f6b7
Removing intermediate container 8f7292364245
Step 6 : RUN cd /opt
 ---> Running in c7d20fd251f3
 ---> 0cdf90b6cb2e
Removing intermediate container c7d20fd251f3
Step 7 : RUN rpm -Uvh auditserver-1-1.x86_64.rpm
 ---> Running in 4473241e5077
error: open of auditserver-1-1.x86_64.rpm failed: No such file or directory
The command '/bin/sh -c rpm -Uvh auditserver-1-1.x86_64.rpm' returned a non-zero code: 1
root@CloudieBase:/tmp/sky-test# 

Can any help on this to made perfect Dockerfile. thanks.

lvthillo
  • 20,087
  • 10
  • 71
  • 108
Skylab
  • 21
  • 1
  • 4

1 Answers1

0

The problem is that you are not in the /opt directory when executing the rpm command (step 7). See this answer to find out why it happens. Quote:

Each time you RUN, you spawn a new container and therefore the pwd is '/'.

For how to fix it see this question. To summarize: you can use the WORKDIR dockerfile command or change this part:

RUN cd /opt
RUN rpm -Uvh auditserver-1-1.x86_64.rpm

to this:

RUN cd /opt && rpm -Uvh auditserver-1-1.x86_64.rpm
Community
  • 1
  • 1
jannis
  • 3,430
  • 15
  • 38