Docker failed to install img2pdf specifically permission denied on python3-pkg-resources - python-3.x

I have a docker file like this
FROM node:18
RUN apt-get update
RUN apt-get -y install img2pdf
RUN apt-get -y install dcmtk
WORKDIR /app
COPY package.json ./
RUN yarn install
RUN yarn global add pm2 -g
COPY . .
which working smoothly on my mac m1.
But when deploying it to ubuntu 22 machine,
it failed with bunch of permission denied python3-related issue
I've tried bunch of things including reiinstall python3 and python3-pkg-resources, which make my dockerfile now looks like this
FROM node:18
RUN apt-get clean
RUN apt-get update
RUN apt-get -y reinstall python3
RUN apt-get -y reinstall python3-pkg-resources
RUN apt-get -y install img2pdf
RUN apt-get -y install dcmtk
WORKDIR /app
COPY package.json ./
RUN yarn install
RUN yarn global add pm2 -g
COPY . .
now show this error

I don't have much knowledge around docker and computer CPU.
But so far my problem happens when I run the docker on intel machine. Now I move my production server using AMD vCPU. it run as local
Would be lovely if anyone have reference the reason for it. and what people could do

Related

gulp not running on Docker ubuntu

I'm trying to use gulp to start a webpack compiler in a docker environment. Wheneever I try to run the command (in ssh, the Dockerfile, or the Procfile) it fails with error code 1 and prints nothing.
I checked and gulp is installed in node_packages, but when I run it from node_packages/.bin I get the same response. Running "npm" works, but running "node" appears not to work either.
Does anyone know what is going wrong?
Dockerfile
FROM quay.io/aptible/ubuntu:14.04
# Basic dependencies
RUN apt-install build-essential python-dev python-setuptools
RUN apt-install libxml2-dev libxslt1-dev python-dev
# PostgreSQL dev headers and client (uncomment if you use PostgreSQL)
# RUN apt-install libpq-dev postgresql-client-9.3 postgresql-contrib-9.3
# MySQL dev headers (uncomment if you use MySQL)
RUN apt-install libmysqlclient-dev
RUN easy_install pip
RUN apt-install node
RUN apt-install npm
# Add requirements.txt and package.json ONLY, then run pip install, so that Docker cache won't
# bust when changes are made to other repo files
ADD requirements.txt /app/
ADD package.json /app/
WORKDIR /app
RUN pip install -r requirements.txt
RUN npm install
# Add repo contents to image
ADD . /app/
# RUN npm install -g gulp
# RUN gulp webpack:dev
#django environment variables
# ENV DATABASE_URL xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# ENV SECRET_KEY xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# ENV DJANGO_SETTINGS_MODULE xxxxxxxxxxxxx
ENV PORT 3000
EXPOSE 3000
procfile
web: sudo node_modules/.bin/gulp webpack:dev && sudo python app/manage.py runserver 0.0.0.0:$PORT
Change these lines
RUN apt-install build-essential python-dev python-setuptools
...
RUN apt-install node
RUN apt-install npm
to these:
RUN apt-install build-essential curl python-dev python-setuptools
...
RUN curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
RUN apt-get install -y nodejs
You'll note we added curl to your tool installation and we're grabbing the node ppa, then installing it. This is going to give you the more current version of node on that branch. It will also come with npm, you do not need to install that separately.
Uncomment this line, as you want gulp to be a global install
# RUN npm install -g gulp
Correspondingly, in your proc file - use the global gulp

Whois with NodeJS Docker Image

I'm trying to get Whois working in NodeJS on a Dockerfile. I'm using Whois-UX (which just spawns a whois process with the whois linux command. I'm using the "node:argon" docker image, but it doesn't have whois installed. There doesn't seem to be a way to apt-get install whois inside the image either.
I then tried to use "ubuntu:12.04", but I'm having trouble running the app with it. Here is my Dockerfile:
FROM ubuntu:12.04
WORKDIR /srv
ADD . /srv
RUN apt-get update
RUN apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup | bash -
RUN apt-get install -y nodejs git git-core whois
RUN npm install
CMD ["node /srv/server.js"]
So, there are two possible solutions that I don't know how to solve. Figure out how to get whois on the node:argon image, or get the ubuntu docker image to work. I'd rather get whois on node:argon, because of optimizations for NodeJS, but as long as it works, it'll do.
Thanks for the help!
Whelp. I got it.
I forgot to apt-get update before I apt-get installed whois, so it didn't show the repository as being up.
FROM node:argon
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
RUN apt-get update
RUN apt-get install whois
RUN npm install bower -g
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
RUN bower install --allow-root
CMD ["npm", "start"]
^ This worked.

Docker with Node.js and Express.js

I'm trying to use docker with my node application, my Dockerfile looks like this:
RUN apt-get update
RUN apt-get -y install build-essential
RUN apt-get install -y nodejs
RUN apt-get install -y npm
ADD . /src
RUN cd /src && npm install
EXPOSE 8080
CMD ["node","/src/app.js"]
but after running docker build when npm install is running after trying to install https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.2.tgz I get an error:
The command 'bin/sh -c /src && npm install' returned a non-zero code : 1
What can cause such an issue? I've already tried to install node-legacy instead of node and it didn't work
Try this:
# put this line on your code (if you are using ubuntu)
# this make a link from nodejs to node to add compatibility on ubuntu OS
RUN ln -s /usr/bin/nodejs /usr/bin/node
# set your current directory with WORKDIR
WORKDIR /src
RUN sudo npm install

Issue running Gulp on Docker

I have the following Dockerfile
FROM debian:jessie
MAINTAINER Ewan Valentine <ewan#theladbible.com>
WORKDIR /tmp
RUN apt-get update -y && \
apt-get install -y \
curl
RUN curl --silent --location https://deb.nodesource.com/setup_0.12 | bash -
RUN apt-get install --yes nodejs
VOLUME ["/var/www/admin/src"]
RUN mkdir -p /var/www/admin/src
WORKDIR /var/www/admin/src
RUN npm install -g gulp
ENTRYPOINT ["gulp"]
However, when I run $ docker-compose run gulp I get the following error:
[10:47:49] Local gulp not found in /var/www/admin/src
[10:47:49] Try running: npm install gulp
I'm using docker-compose and this container is linked to a volume where the source code is kept, which all runs fine otherwise.
I was liking to the wrong volume! Sorted now.

docker command attach running slow

i have docker container that adds 3 volumes and links to one other docker container. this linked container links to another one.
the container contains a nodejs server that is listening on one port.
the time for starting up the container is very short.
if i try to attach to that container it tooks sometimes 3 minutes until the attach-command runs.
could anyone give me a reason why the attach command tooks so long to start?
This is my Dockerfile:
FROM ubuntu:trusty
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update
RUN apt-get -y install curl
RUN apt-get -y install nodejs
RUN apt-get -y install npm
RUN npm install forever -g
RUN npm install n -g
RUN n 0.11.11
RUN npm install gulp -g
RUN mkdir -p data/dmcms-static-ng
RUN mkdir -p data/site-ng
RUN mkdir -p data/static-ng
ADD app-run.sh /app-run.sh
RUN chmod 755 /*.sh

Resources