My Dockerfile
FROM debian:jessie-20180831 as builder
ENV BUILD_DEPS "curl git"
COPY . /go/src/chaochaogege.com/onlinecode
WORKDIR /go/src/chaochaogege.com/onlinecode
RUN apt-get update && apt-get install curl git sudo --no-install-recommends -y
RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E sh -;\
apt-get install nodejs -y --no-install-recommends;
RUN cd ./client-side \
&& npm install && npm run build;
COPY ./sql ./client-side/dist/
RUN apt-get update && apt-get install ${BUILD_DEPS} -y --no-install-recommends;\
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh; \
dep ensure -update;\
go install;
FROM golang:1.11.1-alpine3.7
RUN mkdir -p /go/src/chaochaogege.com/onlinecode
WORKDIR /go/src/chaochaogege.com/onlinecode
COPY --from=builder /go/bin/onlinecode .
COPY --from=builder /go/src/chaochaogege.com/onlinecode/client-side/dist/* .
EXPOSE 8086
ENTRYPOINT ["onlinecode"]
I don't know my happened.
From my view, I install nodejs in RUN layer, and then use npm in another layer after it.
But why not work?
There are some dupicate questions I am sure, but all of them not solve my problem.
I guess maybe npm only can be used in same docker layer? So I change Dockerfile to follow:
FROM debian:jessie-20180831 as builder
ENV BUILD_DEPS "curl git"
COPY . /go/src/chaochaogege.com/onlinecode
WORKDIR /go/src/chaochaogege.com/onlinecode
RUN apt-get update && apt-get install curl git sudo --no-install-recommends -y
RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E sh -;\
apt-get install nodejs -y --no-install-recommends;\
npm --version; \
cd ./client-side \
&& npm install && npm run build;
COPY ./sql ./client-side/dist/
RUN apt-get update && apt-get install ${BUILD_DEPS} -y --no-install-recommends;\
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh; \
dep ensure -update;\
go install;
FROM golang:1.11.1-alpine3.7
RUN mkdir -p /go/src/chaochaogege.com/onlinecode
WORKDIR /go/src/chaochaogege.com/onlinecode
COPY --from=builder /go/bin/onlinecode .
COPY --from=builder /go/src/chaochaogege.com/onlinecode/client-side/dist/* .
EXPOSE 8086
ENTRYPOINT ["onlinecode"]
But also get result
npm not found
Error log
Step 6/15 : RUN curl -sL https://deb.nodesource.com/setup_8.x | sudo -E sh -; apt-get install nodejs -y --no-install-recommends; npm --version; cd ./client-side && npm install && npm run build;
---> [Warning] Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
---> Running in 2788863ccf8a
Reading package lists...
Building dependency tree...
Reading state information...
The following extra packages will be installed:
libc-ares2 libv8-3.14.5
The following NEW packages will be installed:
libc-ares2 libv8-3.14.5 nodejs
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 1990 kB of archives.
After this operation, 7495 kB of additional disk space will be used.
Get:1 http://deb.debian.org/debian/ jessie/main libc-ares2 amd64 1.10.0-2+deb8u2 [72.5 kB]
Get:2 http://deb.debian.org/debian/ jessie/main libv8-3.14.5 amd64 3.14.5.8-8.1 [1269 kB]
Get:3 http://deb.debian.org/debian/ jessie/main nodejs amd64 0.10.29~dfsg-2 [648 kB]
[91mdebconf: delaying package configuration, since apt-utils is not installed
[0mFetched 1990 kB in 1s (1874 kB/s)
Selecting previously unselected package libc-ares2:amd64.
(Reading database ... (Reading database ... 5% (Reading database ... 10% (Reading database ... 15% (Reading database ... 20% (Reading database ... 25% (Reading database ... 30% (Reading database ... 35% (Reading database ... 40% (Reading database ... 45% (Reading database ... 50% (Reading database ... 55% (Reading database ... 60% (Reading database ... 65% (Reading database ... 70% (Reading database ... 75% (Reading database ... 80% (Reading database ... 85% (Reading database ... 90% (Reading database ... 95% (Reading database ... 100% (Reading database ... 9841 files and directories currently installed.)
Preparing to unpack .../libc-ares2_1.10.0-2+deb8u2_amd64.deb ...
Unpacking libc-ares2:amd64 (1.10.0-2+deb8u2) ...
Selecting previously unselected package libv8-3.14.5.
Preparing to unpack .../libv8-3.14.5_3.14.5.8-8.1_amd64.deb ...
Unpacking libv8-3.14.5 (3.14.5.8-8.1) ...
Selecting previously unselected package nodejs.
Preparing to unpack .../nodejs_0.10.29~dfsg-2_amd64.deb ...
Unpacking nodejs (0.10.29~dfsg-2) ...
Setting up libc-ares2:amd64 (1.10.0-2+deb8u2) ...
Setting up libv8-3.14.5 (3.14.5.8-8.1) ...
Setting up nodejs (0.10.29~dfsg-2) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Processing triggers for libc-bin (2.19-18+deb8u10) ...
[91m/bin/sh: 1: npm: not found
With apt-get install nodejs you install only node, but not npm itself. You can check the nodejs files in the debian package index.
To install npm you need to install the npm package.
So, to fix your Dockerfile edit this line:
apt-get install nodejs -y --no-install-recommends;
With:
apt-get install nodejs npm -y --no-install-recommends;
Related
My Dockerfile look like this:
FROM python:3-ubuntu20.04
ENV PATH="/opt/venv/bin:$PATH"
ENV ON_DOCKER=1
RUN echo "Acquire::http::Proxy \"http://webproxy.ecorp.com:8080/\";" >> /etc/apt/apt.conf.d/apt.conf
RUN echo "Acquire::https::Verify-Peer \"false\";" >> /etc/apt/apt.conf.d/apt.conf
RUN echo "Acquire::https::Verify-Host \"false\";" >> /etc/apt/apt.conf.d/apt.conf
RUN apt-get update -y --allow-insecure-repositories
# RUN sleep 10
RUN apt-get upgrade -y
RUN apt-get install -y -f --allow-unauthenticated python3-venv
RUN python3 -m venv /opt/venv && \
python3 -m ensurepip && \
pip3 install --no-cache wheel && \
pip3 install --no-cache setuptools_scm
COPY package /package/
RUN cd package/ && \
pip install . && \
cd .. && \
rm -r package/
COPY app/requirements.txt requirements.txt
RUN pip install -r requirements.txt
As you can see I need to work a bit around our proxy server to get to the ubuntu repositories.
I run the "podman build ..." always as root and also the app inside is supposed to run as root.
However I get this strange error:
(Reading database ... 100%
(Reading database ... 14378 files and directories currently installed.)
16:45:07 Preparing to unpack .../python3.8-venv_3.8.10-0ubuntu1~20.04.2_amd64.deb ...
16:45:07 Unpacking python3.8-venv (3.8.10-0ubuntu1~20.04.2) ...
16:45:07 dpkg: error processing archive /var/cache/apt/archives/python3.8-venv_3.8.10-0ubuntu1~20.04.2_amd64.deb (--unpack):
16:45:07 error setting timestamps of '/usr/share/doc/python3.8-venv.dpkg-new': Permission denied
16:45:07 Selecting previously unselected package python3-venv.
16:45:07 Preparing to unpack .../python3-venv_3.8.2-0ubuntu2_amd64.deb ...
16:45:07 Unpacking python3-venv (3.8.2-0ubuntu2) ...
16:45:07 dpkg: error processing archive /var/cache/apt/archives/python3-venv_3.8.2-0ubuntu2_amd64.deb (--unpack):
16:45:07 error setting timestamps of '/usr/bin/pyvenv.dpkg-new': Permission denied
16:45:07 Errors were encountered while processing:
16:45:07 /var/cache/apt/archives/python3.8-venv_3.8.10-0ubuntu1~20.04.2_amd64.deb
16:45:07 /var/cache/apt/archives/python3-venv_3.8.2-0ubuntu2_amd64.deb
16:45:07 E: Sub-process /usr/bin/dpkg returned an error code (1)
16:45:07 Error: error building at STEP "RUN apt-get install -y -f --allow-unauthenticated python3-venv": error while running runtime: exit status 100
I've no explanation why this happens or cause ? There is no SELinux nor AppArmor active ...
I even had a "RUN id" inside the Dockerfile to verify being root.
Any ideas ?
I have an error when trying to install the libmysqlclient-dev package together with npm for some reason when installing libmysqlclient-dev it removes npm
Step 10/26 : RUN apt-get install -y libmysqlclient-dev
---> Running in beae8aee9cd4
Reading package lists...
Building dependency tree...
Reading state information...
The following packages were automatically installed and are no longer required:
gyp javascript-common libjs-async libjs-inherits libjs-jquery
libjs-node-uuid libjs-underscore libuv1-dev node-abbrev node-ansi
node-ansi-color-table node-archy node-async node-balanced-match
node-block-stream node-brace-expansion node-builtin-modules
node-combined-stream node-concat-map node-cookie-jar node-delayed-stream
node-forever-agent node-form-data node-fs.realpath node-fstream
node-fstream-ignore node-github-url-from-git node-glob node-graceful-fs
node-hosted-git-info node-inflight node-inherits node-ini
node-is-builtin-module node-isexe node-json-stringify-safe node-lockfile
node-lru-cache node-mime node-minimatch node-mkdirp node-mute-stream
node-node-uuid node-nopt node-normalize-package-data node-npmlog node-once
node-osenv node-path-is-absolute node-pseudomap node-qs node-read
node-read-package-json node-request node-retry node-rimraf node-semver
node-sha node-slide node-spdx-correct node-spdx-expression-parse
node-spdx-license-ids node-tar node-tunnel-agent node-underscore
node-validate-npm-package-license node-which node-wrappy node-yallist
Use 'apt autoremove' to remove them.
The following additional packages will be installed:
libssl-dev
Suggested packages:
libssl-doc
The following packages will be REMOVED:
libssl1.0-dev node-gyp nodejs-dev npm
The following NEW packages will be installed:
libmysqlclient-dev libssl-dev
0 upgraded, 2 newly installed, 4 to remove and 133 not upgraded.
Need to get 2,583 kB of archives.
After this operation, 5,175 kB disk space will be freed.
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libssl-dev amd64 1.1.1-1ubuntu2.1~18.04.9 [1,566 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmysqlclient-dev amd64 5.7.34-0ubuntu0.18.04.1 [1,016 kB]
dpkg-preconfigure: unable to re-open stdin:
Fetched 2,583 kB in 2s (1,412 kB/s)
(Reading database ... 25174 files and directories currently installed.)
Removing npm (3.5.2-0ubuntu4) ...
Removing node-gyp (3.6.2-1ubuntu1) ...
Removing nodejs-dev (8.10.0~dfsg-2ubuntu0.4) ...
Removing libssl1.0-dev:amd64 (1.0.2n-1ubuntu5.6) ...
That gives me the following error:
Step 14/26 : RUN npm install -g npm#4.1.1
---> Running in 18f70438b2ae
/bin/sh: 1: npm: not found
ERROR: Service 'webapp' failed to build: The command '/bin/sh -c npm install -g npm#4.1.1' returned a non-zero code: 127
This is my Dockerfile:
RUN apt-get update
RUN apt-get install -y tzdata
RUN apt-get install -y libfontconfig1
RUN apt-get install -y libxrender1
RUN apt-get install -y nodejs
RUN apt-get install -y npm
RUN apt-get install -y yarn
RUN apt-get install -y mysql-client
RUN apt-get install -y libmysqlclient-dev
RUN apt-get install -y shared-mime-info
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN npm install -g npm#4.1.1
RUN npm install -g yarn
I am working on ruby on rails and I need the libmysqlclient-dev package for the mysql2 gem
How can i fix this?
You will want to read the Dockerfile best practices for the RUN instruction from the Docker docs. Each line in a Dockerfile is an image layer and the state after a RUN instruction is executed command is not always persisted on the next layer.
So the apt-get install -y npm won't affect the build when you run npm install -g ... so you received the error: npm command not found.
Please read the guide and attempt to use this single RUN instruction instead.
RUN apt-get update \
&& apt-get install -y tzdata \
&& apt-get install -y libfontconfig1 \
&& apt-get install -y libxrender1 \
&& apt-get install -y nodejs \
&& apt-get install -y npm \
&& apt-get install -y yarn \
&& apt-get install -y mysql-client \
&& apt-get install -y libmysqlclient-dev \
&& apt-get install -y shared-mime-info \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
&& npm install -g npm#4.1.1 \
npm install -g yarn
using a new node that comes with npm helped for me:
apt-get -qq update && \
apt-get -qq --no-install-recommends install curl && \
curl -sL https://deb.nodesource.com/setup_17.x | bash - && \
apt-get -qq --no-install-recommends install \
openssl \
nodejs \
linux-headers-generic \
tzdata \
libmysqlclient-dev
In Ubuntu 18.04 (bionic) there is a conflict between libmysqlclient-dev and the npm packages, one requires libssl1.0-dev and the other libssl-dev:
The following packages have unmet dependencies:
libssl-dev : Conflicts: libssl1.0-dev but 1.0.2n-1ubuntu5.9 needs to be installed.
libssl1.0-dev : Conflicts: libssl-dev but must install 1.1.1-1ubuntu2.1~18.04.17
It's not related to the way you were using docker, but to a conflict in the packages themselves. The easiest workaround is to install node from upstream:
RUN curl -sL https://deb.nodesource.com/setup_17.x | bash - && apt-get install -y nodejs
I have a dockerfile to upload some python code on Azure. It has been working for a few months, but today it suddenly stopped working.
The relevant commands in the Dockerfile are:
FROM python:3.9.5
:
:
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN exit
RUN apt-get update && ACCEPT_EULA=Y apt-get install msodbcsql17
The error message is that appeared today is:
Err:1 https://packages.microsoft.com/ubuntu/20.04/prod focal/main amd64 msodbcsql17 amd64 17.7.2.1-1
404 Not Found [IP: 104.214.230.139 443]
E: Failed to fetch https://packages.microsoft.com/ubuntu/20.04/prod/pool/main/m/msodbcsql17/msodbcsql17_17.7.2.1-1_amd64.deb 404 Not Found [IP: 104.214.230.139 443]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?
The command '/bin/sh -c apt-get update && ACCEPT_EULA=Y apt-get install msodbcsql17' returned a non-zero code: 100
2021/06/16 20:50:56 Container failed during run: build. No retries remaining.
failed to run step ID: build: exit status 100
I believe this might be related to the .deb files being moved - or that some computer at Microsoft is down?
A good workaround would maybe be to download the relevant msodbcsql17 package directly, but I was unable to find this package in the normal repos?
There seems to be some ongoing trouble with microsoft repos for some linux distributions (including ubuntu and debian). Not clear when this will be fixed.
https://github.com/dotnet/core/issues/6381
https://github.com/MicrosoftDocs/sql-docs/issues/6494
The answer might be related to this post:
https://github.com/dotnet/core/issues/6381
It seems that some Ubuntu repositories are broken.
Hopefully it will be fixed soon...
I Will keep an eye on the resolve, but I have the same issue using:
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
WORKDIR /code
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
RUN apt-get update
RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17
# optional: for bcp and sqlcmd
RUN ACCEPT_EULA=Y apt-get install -y mssql-tools
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
RUN echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
# optional: for unixODBC development headers
RUN apt-get install -y unixodbc-dev
I'm stuck on this. I'm building a docker image via the this dockerfile
#
# Nginx Custom Domain Https Dockerfile
#
# Builds an OpenResty nginx image with auto-ssl capabilities
# See: https://github.com/GUI/lua-resty-auto-ssl
#
FROM openresty/openresty:latest-xenial
RUN apt-get update
RUN apt-get install -y apt-transport-https
RUN apt-get install -y --no-install-recommends apt-utils
RUN echo "license_key: 64553f3xxxxxxxxx" | tee -a /etc/newrelic-infra.yml
RUN curl https://download.newrelic.com/infrastructure_agent/gpg/newrelic-infra.gpg | apt-key add -
RUN printf "deb [arch=amd64] https://download.newrelic.com/infrastructure_agent/linux/apt xenial main" | tee -a /etc/apt/sources.list.d/newrelic-infra.list
RUN cat /etc/apt/sources.list.d/newrelic-infra.list
RUN echo "license_key: 64553fxxxxxxxxxxxx" | tee -a /etc/newrelic-infra.yml
RUN cat /etc/newrelic-infra.yml
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -yq newrelic-infra
....
# there is more but see the issue below
I run it with
docker build -t XXXXXXXXXX.dkr.ecr.us-west-2.amazonaws.com/qwilr-codebuild-base:latest .
The output of it is:
Sending build context to Docker daemon 41.47kB
Step
1/19 : FROM openresty/openresty:latest-xenial
....
Step 9/19 : RUN echo "license_key: 64553f38xxxxxxxx" | tee
-a /etc/newrelic-infra.yml
---> Using cache
---> 77cd0ece8528
Step 10/19 : RUN cat /etc/newrelic-infra.yml
---> Using cache
---> 2cb1a27b4d8b
Get:1 https://download.newrelic.com/infrastructure_agent/linux/apt xenial/main amd64 newrelic-infra amd64 1.2.15 [4679 kB]
Fetched 4679 kB in 14s (325 kB/s)
Selecting previously unselected package newrelic-infra.
(Reading database ... 15601 files and directories currently installed.)
Preparing to unpack .../newrelic-infra_1.2.15_amd64.deb ...
Unpacking newrelic-infra (1.2.15) ...
Setting up newrelic-infra (1.2.15) ...
Failed to connect to bus: No such file or directory
dpkg: error processing package newrelic-infra (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
newrelic-infra
E: Sub-process /usr/bin/dpkg returned an error code (1)
The command '/bin/sh -c DEBIAN_FRONTEND=noninteractive apt-get install -yq newrelic-infra' returned a non-zero code: 100
The problem seems to be that adding the newrelic-infra.yml file just does not work. I've also tried COPY and ADD. Is there something I'm missing which would cause this file to not be there for the following apt-get install command.
I have also run with --no-cache and still get the same error. The key failure I believe is that newrelic-infra install expects the file /etc/newrelic-infra.yml to be there, as highlighted by the line Failed to connect to bus: No such file or directory
Is there a reason why files copied to /etc/ are failing? Is it the base image I'm using?
It looks like it an open issue.
dpkg error processing package newrelic-infra
Also, the package is missing under
linux/apt
I'm trying to install jre in a docker-container, and use
RUN apt-get install -y openjdk-7-jre to install jre in my container. When I started to build it, the process blocked at this command:
Setting up ca-certificates-java (20140324)...
Here is the screenshot:screenshot
My dockerfile is from debian:jessie:
COPY ./data /runtime/data
RUN chmod 777 -R /runtime/data
RUN apt-get update && \
apt-get install -y openjdk-7-jre && \
apt-get install -y screen && \
rm -rf /var/lib/apt/lists/*
I have no problem:
[...]
Setting up openjdk-7-jre:amd64 (7u101-2.6.6-1~deb8u1) ...
update-alternatives: using /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/policytool to provide /usr/bin/policytool (policytool) in auto mode
Setting up ca-certificates-java (20140324) ...
done.
Processing triggers for libc-bin (2.19-18+deb8u4) ...
Processing triggers for systemd (215-17+deb8u4) ...
Processing triggers for ca-certificates (20141019+deb8u1) ...
Updating certificates in /etc/ssl/certs... 174 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d....
[...]
What is your Docker version ?