Getting "can't cd" error when when building using dockerfile - node.js

This is the complete dockerfile
FROM ubuntu:12.04
# Create directory
RUN mkdir -p /dir/subdir
# Download wget
RUN apt-get install -y wget
# Make sure package is up to date
RUN apt-get update
# Install nodejs
WORKDIR /dir
RUN wget http://nodejs.org/dist/v0.10.26/node-v0.10.26-linux-x64.tar.gz
RUN tar -zxf node-v0.10.26-linux-x64.tar.gz
RUN cd /node-v0.10.26-linux-x64 && ./configure
RUN cd /node-v0.10.26-linux-x64 && make
RUN cd /node-v0.10.26-linux-x64 && make install
# Update again
RUN apt-get-update
# Copy all the files
ADD dir/subdir dir/subdir
EXPOSE 8080
CMD ["node", "/dir/subdir/index.js"]
This is part of the log where it gets an error
Step 6 : RUN tar -zxf node-v0.10.26-linux-x64.tar.gz
---> Running in xxxxxxx
---> xxxxxxxxxxxxxx
Removing intermediate container xxxxxxxxxxxx
Step 7 : RUN cd /node-v0.10.26-linux-x64 && ./configure
---> Running in xxxxxxxx
[91m/bin/sh: 1: cd: can't cd to /node-v0.10.26-linux-x64
[0m
The command [/bin/sh -c cd /node-v0.10.26-linux-x64 && ./configure] returned a non-zero code: 2
Does anyone know what the error 2 means and how to fix it?

This time I tested it.
FROM ubuntu:12.04
# Create directory
RUN mkdir -p /dir/subdir
# Make sure package is up to date
RUN apt-get update
# Install dependencies
RUN apt-get install -y build-essential openssl libssl-dev pkg-config python
# Install nodejs
WORKDIR /dir
ADD http://nodejs.org/dist/v0.10.29/node-v0.10.29.tar.gz /dir/
RUN tar -zxf node-v0.10.29.tar.gz
WORKDIR /dir/node-v0.10.29
RUN ./configure && make && make install
WORKDIR /dir
# Copy all the files
ADD dir/subdir dir/subdir
EXPOSE 8080
CMD ["node", "/dir/subdir/index.js"]

Docker (v1.0.0) will use WORKDIR for subsequent RUN. cd /node-v0.10.26-linux-x64 won't work as the untar occured in /dir.

Related

docker deploy nuxtjs application error code 100

I'm deploying NuxtJs project to live server but getting error
E: Unable to locate package tini
{"code":100,"message":"The command '/bin/sh -c apt-get update && apt-get install -y tini' returned a non-zero code: 100"}
The command '/bin/sh -c apt-get update && apt-get install -y tini' returned a non-zero code: 100
Build has failed!
Dockerfile:
FROM node:14.15.1
RUN apt-get update && apt-get install -y
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=TRUE
RUN apk add --no-cache su-exec
# create destination directory
RUN mkdir -p /usr/src/nuxt-app
WORKDIR /usr/src/nuxt-app
# update and install dependency
RUN apk update && apk upgrade
RUN apk add git
# copy the app, note .dockerignore
COPY . /usr/src/nuxt-app/
RUN npm install
RUN npm run build
EXPOSE 3000
ENV NUXT_HOST=127.0.0.1
ENV NUXT_PORT=3000
CMD \[ "npm", "start" \]
# Set any ENVs
ARG BASE_URL=${BASE_URL}
ARG BASE_URL_WITHOUT_API=${BASE_URL_WITHOUT_API}
ARG NUXT_ENV_BASE_URL=${NUXT_ENV_BASE_URL}

Dockerfile autorun bash script report error

I have a script which I want dockerfile autorun after image build container, I know it should be entrypoint command,but it doesnt work for me. Can someone help me to point out what is wrong for me
FROM centos:7.7.1908
ENV container docker
RUN yum install -y wget
RUN wget https://github.com/MGI-EU/ToolScieu.network_monitor.v1.0/network_monitor_scripts.zip
RUN yum install -y unzip
#RUN ls
RUN unzip network_monitor_scripts.zip
#RUN unzip /root/network_monitor_scripts.zip
#RUN unzip -d /filess network_monitor_scripts.zip
RUN yum -y install net-tools
RUN yum -y install sed.x86_64
RUN chmod +x /filess/main2.bash
#RUN bash -c "filess/main2.bash"
#RUN ["chmod", "+x", "/filess/main2.bash"]
#RUN cp /filess/main2.bash /main2.bash
#CMD /filess/main2.bash
ENTRYPOINT [ "main2.bash" ]
#ENTRYPOINT /filess/main2.bash

can't do copy using docker and getting error as directory not found?

When I'm trying to install packages using docker
I'm getting the following error
COPY failed: stat /var/lib/docker/overlay2/7f434dda3e872abd56226080297095cbc3ebd1decef703550c2c12fead4a6e94/merged/home/site/wwwroot: no such file or directory
here is my dockerfile
COPY . /home/site/wwwroot
FROM ubuntu
# ...
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && \
apt-get -y install gcc mono-mcs && \
rm -rf /var/lib/apt/lists/*
COPY --from=0 /home/site/wwwroot /home/site/wwwroot
RUN cd /home/site/wwwroot && pip install -r requirements.txt
how to resolve it?
You can also try : Just make sure your pip path is correct, do which pip to make sure what the pip path is.
Then put this in your docker file instead of the last line:
...
RUN /usr/bin/pip -r /home/site/wwwroot/requirements.txt
Let me know if you don't understand my answer.

Error using Oracle Instant Client Docker image

our app is nodejs based and needs to query Oracle DB, so we install NPM oracledb package. So our Docker image is based on oracle instant client, the Docker file looks like following:
FROM frolvlad/alpine-glibc
RUN apk update && apk add libaio
COPY instantclient_12_1.zip ./
RUN unzip instantclient_12_1.zip
RUN mv instantclient_12_1/ /usr/lib/
RUN rm instantclient_12_1.zip
RUN ln /usr/lib/instantclient_12_1/libclntsh.so.12.1 /usr/lib/libclntsh.so
RUN ln /usr/lib/instantclient_12_1/libocci.so.12.1 /usr/lib/libocci.so
RUN ln /usr/lib/instantclient_12_1/libociei.so /usr/lib/libociei.so
RUN ln /usr/lib/instantclient_12_1/libnnz12.so /usr/lib/libnnz12.so
ENV ORACLE_BASE /usr/lib/instantclient_12_1
ENV LD_LIBRARY_PATH /usr/lib/instantclient_12_1
ENV TNS_ADMIN /usr/lib/instantclient_12_1
ENV ORACLE_HOME /usr/lib/instantclient_12_1
RUN apk add nodejs npm
RUN mkdir -p /var/app
WORKDIR /var/app
ADD package.json /var/app
COPY . /var/app
CMD ["npm","start"]
But when our app starts using 'oracledb' NPM package, it got following error:
init() error: DPI-1047: Cannot locate a 64-bit Oracle Client library: "Error loading shared library libnsl.so.1: No such file or directory (needed by /usr/lib/libclntsh.so)". See https://oracle.github.io/odpi/doc/installation.html#linux for help Node-oracledb installation instructions: https://oracle.github.io/node-oracledb/INSTALL.html
You must have 64-bit Oracle client libraries in LD_LIBRARY_PATH, or configured with ldconfig.
If you do not have Oracle Database on this computer, then install the Instant Client Basic or Basic Light package from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
So Oracle client couldn't find libnsl.so.1 even thought it should come with glibc, and I can see that it is under:
'/usr/glibc-compat/lib'.
Any ideas how to fix this? Thanks in Advance.
# 1. Install dependencies
FROM node:8.15 as cache-package
COPY package.json /srv/src/package.json
WORKDIR /srv/src
RUN yarn install
# 2.
FROM node:8.15 as builder
# 1. Update everything on the box
RUN apt-get update && \
apt-get install sudo
#RUN apk --update add libaio bc net-tools
RUN sudo apt-get install unzip
RUN sudo apt-get install wget
RUN sudo apt-get install git
# 3. Install oracle client
RUN mkdir -p /opt/oracle
# 3.1 Get oracle client
WORKDIR /opt/oracle
RUN wget -O /opt/oracle/instantclient_18_3_linux.zip http://YOUR_URL_TO_DOWNLOAD_THE_CLIENT/instantclient_18_3_linux.zip
RUN sudo unzip /opt/oracle/instantclient_18_3_linux.zip
# 3.2 Configure oracle client to work with node
RUN sudo sh -c "echo /opt/oracle/instantclient_18_3_linux > /etc/ld.so.conf.d/oracle-instantclient.conf"
RUN sudo cat /etc/ld.so.conf.d/oracle-instantclient.conf
FROM node:8.15
RUN apt-get update && \
apt-get install sudo
RUN sudo apt-get install libaio1
RUN mkdir -p /srv/src/logs
RUN mkdir -p /srv/logs
RUN mkdir -p /opt/oracle
# 4. Set the working directory
# 5. Copy our project & install our dependencies
COPY --from=cache-package /srv/src /srv/src
COPY --from=builder /opt/oracle/instantclient_18_3_linux /opt/oracle/instantclient_18_3_linux
COPY --from=builder /etc/ld.so.conf.d/oracle-instantclient.conf /etc/ld.so.conf.d/oracle-instantclient.conf
RUN sudo ldconfig
RUN ln -sf /usr/share/zoneinfo/WET /etc/localtime
COPY . /srv/src
WORKDIR /srv/src
# 6. Start the app
CMD yarn start
Here is my dockerfile working fine, the srv/src is my directory where I have my code, just change for yours and it should work.
I have the same problem as you the past two days and now it works.

Install nodejs using docker

I have tried the following to install nodes into a centos box but I get an error when it reaches ./configure
Step 6 : RUN tar -zxf node-v0.10.28-linux-x64.tar.gz
---> Running in ebc71472544d
---> c97289348900
Removing intermediate container ebc71472544d
Step 7 : RUN cd /node-v0.10.28-linux-x64
---> Running in 3470f862c586
---> 1771d01a5da0
Removing intermediate container 3470f862c586
Step 8 : RUN ./configure
---> Running in 16a811766136
/bin/sh: ./configure: No such file or directory
My Dockerfile
#Install NodeJS
RUN cd /usr/src
RUN wget http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-x64.tar.gz
RUN tar -zxf node-v0.10.28-linux-x64.tar.gz
RUN cd /node-v0.10.28-linux-x64
RUN ./configure
RUN make &&
RUN make install
Am I using the right way of installing nodes to centos using the Dockerfile?
I'm assuming this isn't the whole Dockerfile, right? Otherwise you're missing at least a FROM.
Try to change the last 4 lines like that:
RUN cd /node-v0.10.28-linux-x64 && ./configure
RUN cd /node-v0.10.28-linux-x64 && make
RUN cd /node-v0.10.28-linux-x64 && make install
or like this
RUN cd /node-v0.10.28-linux-x64 && ./configure && make && make install
As far as I can tell, docker is running each RUN command as a separate shell, so just changing the directory won't be remembered in the next commands.
Here is an example Docker file to test this:
FROM ubuntu
RUN cd /etc
RUN pwd
And here is the build log:
Step 0 : FROM ubuntu
---> 99ec81b80c55
Step 1 : RUN cd /etc
---> Running in a4c25ee340a8
---> 82ad93bdd18c
Removing intermediate container a4c25ee340a8
Step 2 : RUN pwd
---> Running in f535178df40c
/
---> 495c68757268
[EDIT]
Another option is to use WORKDIR, like this:
#Install NodeJS
WORKDIR /usr/src
ADD http://nodejs.org/dist/v0.10.28/node-v0.10.28-linux-x64.tar.gz .
RUN tar -zxf node-v0.10.28-linux-x64.tar.gz
WORKDIR node-v0.10.28-linux-x64
RUN ./configure
RUN make &&
RUN make install
My solution using nvm:
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
RUN source $HOME/.bashrc && nvm install 12.14.1
RUN ln -s $HOME/.nvm/versions/node/v12.14.1/bin/node /usr/bin/node
RUN ln -s $HOME/.nvm/versions/node/v12.14.1/bin/npm /usr/bin/npm
RUN node -v
RUN npm -v

Resources