I'm working on a Ubuntu Linux 20.04
Docker version is: Docker version 20.10.18, build b40c2f6
I have the following Dockerfile file
FROM ubuntu:20.04
LABEL maintainer="Taylor Otwell"
ARG WWWGROUP
ARG NODE_VERSION=16
WORKDIR /var/www/html
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=UTC
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update \
&& apt-get install -y apt-transport-https
RUN apt-get install -y software-properties-common gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 \
&& mkdir -p ~/.gnupg \
&& chmod 600 ~/.gnupg \
&& echo "disable-ipv6" >> ~/.gnupg/dirmngr.conf
RUN LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php \
&& apt-get update \
&& apt-get install -y php8.1-cli php8.1-dev \
php8.1-pgsql php8.1-sqlite3 php8.1-gd \
php8.1-curl \
php8.1-imap php8.1-mysql php8.1-mbstring \
php8.1-xml php8.1-zip php8.1-bcmath php8.1-soap \
php8.1-intl php8.1-readline \
php8.1-ldap \
php8.1-msgpack php8.1-igbinary php8.1-redis php8.1-swoole \
php8.1-memcached php8.1-pcov php8.1-xdebug \
php8.1-amqp php8.1-imagick \
&& sed -i 's/<policy domain="coder" rights="none" pattern="PDF" \/>/<policy domain="coder" rights="read|write" pattern="PDF" \/>/g' /etc/ImageMagick-6/policy.xml \
&& php -r "readfile('https://getcomposer.org/installer');" | php -- --install-dir=/usr/bin/ --filename=composer \
&& curl -sL https://deb.nodesource.com/setup_$NODE_VERSION.x | bash - \
&& apt-get install -y nodejs \
&& npm install -g npm \
&& curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
&& echo "deb https://dl.yarnpkg.com/debian/ stable main" > /etc/apt/sources.list.d/yarn.list \
&& sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list' \
&& curl -sS https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& apt-get update \
&& apt-get install -y yarn \
&& apt-get install -y mysql-client \
&& apt-get install -y postgresql-client-14 \
&& apt-get -y autoremove \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.1
RUN groupadd --force -g $WWWGROUP dstr
RUN useradd -ms /bin/bash --no-user-group -g $WWWGROUP -u 1337 dstr
COPY start-container /usr/local/bin/start-container
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY php.ini /etc/php/8.1/cli/conf.d/99-dstr.ini
RUN chmod +x /usr/local/bin/start-container
EXPOSE 8000
ENTRYPOINT ["start-container"]
Then I run command:
docker build -t np1tshkodenko/api:8.1 .
I got the following output:
shkodenko.t#WSH63676:~/2023-02-07_lara/zoning-backend/docker/api/8.1$ docker build -t np1tshkodenko/api:8.1 .
[+] Building 149.0s (13/18)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 2.62kB 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:20.04 2.8s
=> [auth] library/ubuntu:pull token for registry-1.docker.io 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 1.05kB 0.0s
=> [ 1/13] FROM docker.io/library/ubuntu:20.04#sha256:4a45212e9518f35983a976eead0de5eecc555a2f047134e9dd2cfc589076a00d 2.1s
=> => resolve docker.io/library/ubuntu:20.04#sha256:4a45212e9518f35983a976eead0de5eecc555a2f047134e9dd2cfc589076a00d 0.0s
=> => sha256:4a45212e9518f35983a976eead0de5eecc555a2f047134e9dd2cfc589076a00d 1.13kB / 1.13kB 0.0s
=> => sha256:bffb6799d706144f263f4b91e1226745ffb5643ea0ea89c2f709208e8d70c999 424B / 424B 0.0s
=> => sha256:e40cf56b4be35b04f620bc9cfbef80038fd7370d4ed36d90676223174ecbf0b0 2.30kB / 2.30kB 0.0s
=> => sha256:b549f31133a955f68f9fa0d93f18436c4a180e12184b999a8ecf14f7eaa83309 27.50MB / 27.50MB 1.1s
=> => extracting sha256:b549f31133a955f68f9fa0d93f18436c4a180e12184b999a8ecf14f7eaa83309 0.9s
=> [ 2/13] WORKDIR /var/www/html 0.1s
=> [ 3/13] RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime && echo UTC > /etc/timezone 0.2s
=> [ 4/13] RUN apt-get update && apt-get install -y apt-transport-https 6.6s
=> [ 5/13] RUN apt-get install -y software-properties-common gnupg gosu curl ca-certificates zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 && mkdir -p ~/. 58.5s
=> [ 6/13] RUN LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php && apt-get update && apt-get install -y php8.1-cli php8.1-dev php8.1-pgsql php8.1-sqlite3 php8 78.1s
=> [ 7/13] RUN setcap "cap_net_bind_service=+ep" /usr/bin/php8.1 0.2s
=> ERROR [ 8/13] RUN groupadd --force -g $WWWGROUP dstr 0.2s
------
> [ 8/13] RUN groupadd --force -g $WWWGROUP dstr:
#12 0.211 groupadd: invalid group ID 'dstr'
------
executor failed running [/bin/sh -c groupadd --force -g $WWWGROUP dstr]: exit code: 3
shkodenko.t#WSH63676:~/2023-02-07_lara/zoning-backend/docker/api/8.1$
How can I fix this error to complete a build?
I've tried to execute docker build -t np1tshkodenko/api:8.1 . and I'm expecting to get a working container build.
You need to pass a value for the WWWGROUP variable when you build the image.
I don't know what a sensible value would be, but let's say that you want the value to be 'mygroup'. Then you'd do
docker build -t np1tshkodenko/api:8.1 --build-arg WWWGROUP=mygroup .
Related
My docker-compose.yml:
version: "3.3"
services:
build_and_run_service:
image: myapp:0
build: .
network_mode: host
volumes:
- './bin/cookie:/app/cookie'
- './bin/logs:/app/logs'
- './bin/warehouse:/app/warehouse'
Dockerfile doesn't contain CMD and ENTRYPOINT, so when I execute commands in that order:
docker build --tag myapp:0 .
docker run -d -t myapp:0
docker exec -it <container_id> /bin/bash
It works as expected.
For some reason the container is not working when using docker compose...
Commands order:
docker-compose up -d --build
docker-compose run -d build_and_run_service bash
What's wrong?
Both cases work fine on Windows but not on Ubuntu...
#edit
Dockerfile:
FROM ubuntu:20.04 as runtime
LABEL description="Build and run container - myapp"
RUN apt-get update
RUN apt-get install -y software-properties-common
RUN apt-get install -y nano
RUN apt-get install -y wget
RUN apt-get install -y curl
RUN apt-get install -y make
RUN apt-get install -y build-essential
RUN apt-get install -y tcl zlib1g-dev libssl-dev tk libcurl4-gnutls-dev libexpat1-dev gettext dos2unix
# Compilers
RUN apt-get install -y gcc-10
RUN apt-get install -y g++-10
RUN rm /usr/bin/gcc \
&& ln -s /usr/bin/gcc-10 /usr/bin/gcc
RUN rm /usr/bin/g++ \
&& ln -s /usr/bin/g++-10 /usr/bin/g++
# Postgres dev
RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
RUN wget --no-check-certificate --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN apt-get update
RUN apt-get install -y libpq-dev postgresql-server-dev-13
RUN cd /tmp \
&& wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1g.tar.gz \
&& tar -zxf openssl-1.1.1g.tar.gz \
&& cd openssl-1.1.1g \
&& ./config \
&& make \
&& make install \
&& rm /usr/bin/openssl \
&& ln -s /usr/local/bin/openssl /usr/bin/openssl \
&& ldconfig
RUN cd /tmp \
&& wget --no-check-certificate https://cmake.org/files/v3.19/cmake-3.19.6-Linux-x86_64.tar.gz \
&& tar -zxf cmake-3.19.6-Linux-x86_64.tar.gz \
&& mv cmake-3.19.6-Linux-x86_64 /usr/local/ \
&& ln -s /usr/local/cmake-3.19.6-Linux-x86_64/bin/cmake /usr/bin/cmake
RUN cd /tmp \
&& wget --no-check-certificate https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.31.0.tar.gz \
&& tar -zxf git-2.31.0.tar.gz \
&& cd git-2.31.0 \
&& make prefix=/usr/local all \
&& make prefix=/usr/local install
RUN cd /tmp \
&& wget --no-check-certificate https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.tar.gz \
&& tar -zxf boost_1_75_0.tar.gz \
&& cd boost_1_75_0 \
&& ./bootstrap.sh \
&& ./b2 \
&& ./b2 install
VOLUME ["/app/cookie", "/app/logs", "/app/warehouse"]
WORKDIR /app
COPY . /src
RUN cd /src \
&& mkdir build \
&& cd build
# Some building command
## PRIVATE ##
# Removes tmp
RUN cd /tmp \
&& rm -r *
I get an error when I do docker-compose build.
I am using apple siilcon and I was able to build it with intel without any problems.
Does anyone know if something is wrong?
Contents of docker
RUN apt-get update && apt-get install -y unzip && \
CHROME_DRIVER_VERSION=`curl -sS chromedriver.storage.googleapis.com/LATEST_RELEASE` && \
wget -N http://chromedriver.storage.googleapis.com/$CHROME_DRIVER_VERSION/chromedriver_linux64.zip -P ~/ && \
unzip ~/chromedriver_linux64.zip -d ~/ && \
rm ~/chromedriver_linux64.zip && \
chown root:root ~/chromedriver && \
chmod 755 ~/chromedriver && \
mv ~/chromedriver /usr/bin/chromedriver && \
sh -c 'wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -' && \
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
RUN apt-get update
RUN apt-get install -y google-chrome-stable
Error
=> ERROR [ 5/15] RUN apt-get install -y google-chrome-stable 3.2s
------
> [ 5/15] RUN apt-get install -y google-chrome-stable:
#8 1.090 Reading package lists...
#8 2.038 Building dependency tree...
#8 2.154 Reading state information...
#8 2.214 E: Unable to locate package google-chrome-stable
You can add the platform flag to the FROM statement in your Dockerfile. This will ensure the docker container builds the correct architecture every time.
I used this for Debian Linux and Chrome headless:
FROM --platform=linux/amd64 python:3.9
I'm building an image with the the below Dockerfile.
But after building, when I run npm install it says bash: npm: command not found
I have 2 RUN commands to build 2 layers, the first one is basically to build the Python environment for the image, including installing pyodbc driver and install the necessary packages.
The second layer is to install node.
Which step is wrong with the dockerfile?
ARG VARIANT=3
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}
# Avoid warnings by switching to noninteractive
ENV DEBIAN_FRONTEND=noninteractive
ENV PYTHONUNBUFFERED 1
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
# [Optional] Update UID/GID if needed
RUN if [ "$USER_GID" != "1000" ] || [ "$USER_UID" != "1000" ]; then \
groupmod --gid $USER_GID $USERNAME \
&& usermod --uid $USER_UID --gid $USER_GID $USERNAME \
&& chmod -R $USER_UID:$USER_GID /home/$USERNAME; \
fi
# [Optional] If your requirements rarely change, uncomment this section to add them to the image.
#
COPY requirements.txt /tmp/pip-tmp/
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get -y update \
&& ACCEPT_EULA=Y apt-get -y install msodbcsql17 \
&& ACCEPT_EULA=Y apt-get -y install mssql-tools \
&& echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile \
&& echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc \
&& /bin/bash -c "source ~/.bashrc" \
&& apt-get install -y unixodbc-dev \
&& pip3 install django-mssql-backend \
&& apt-get install -y libgssapi-krb5-2 \
&& pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
&& rm -rf /tmp/pip-tmp
# ** [Optional] Uncomment this section to install additional packages. **
#
RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \
#
# Verify git, process tools, lsb-release (common in install instructions for CLIs) installed
&& apt-get -y install git iproute2 procps lsb-release \
#
# Install pylint
#&& pip install pylint \
#
# Update Python environment based on requirements.txt
# && pip --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
# && rm -rf /tmp/pip-tmp \
#
# Install node for building front-ends
&& apt-get update \
&& apt-get -y install curl gnupg \
&& curl -sL https://deb.nodesource.com/setup_14.x | bash - \
&& apt-get -y install nodejs \
#
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
# Switch back to dialog for any ad-hoc use of apt-get
ENV DEBIAN_FRONTEND=
Debian Nodejs could be boguous. Use official nodejs instructions https://github.com/nodesource/distributions/blob/master/README.md#debinstall to install nodejs.
I have the following Dockerfile:
# We will use Ubuntu for our image
FROM ubuntu:latest
# Updating Ubuntu packages
ARG CLOJURE_TOOLS_VERSION=1.10.1.507
RUN apt-get -qq update && apt-get -qq -y install curl wget bzip2 openjdk-8-jdk-headless \
&& curl -sSL https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -o /tmp/miniconda.sh \
# && curl -sSL https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o /tmp/miniconda.sh \
&& bash /tmp/miniconda.sh -bfp /usr/local \
&& rm -rf /tmp/miniconda.sh \
&& conda install -y python=3 \
&& conda update conda \
&& curl -o install-clojure https://download.clojure.org/install/linux-install-${CLOJURE_TOOLS_VERSION}.sh \
&& chmod +x install-clojure \
&& ./install-clojure && rm install-clojure \
# no need to install lein
&& wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein \
&& chmod a+x lein \
&& mv lein /usr/bin \
&& apt-get -qq -y autoremove \
&& apt-get autoclean \
&& rm -rf /var/lib/apt/lists/* /var/log/dpkg.log \
&& conda clean --all --yes
ENV PATH /opt/conda/bin:$PATH
RUN conda create -n pyclj python=3.7 && conda install -n pyclj numpy mxnet \
&& conda install -c conda-forge opencv
## To install pip packages into the pyclj environment do
RUN conda run -n pyclj python3 -mpip install numpy opencv-python
FROM openjdk:8-alpine
RUN lein uberjar
COPY target/uberjar/vendo.jar /vendo/app.jar
EXPOSE 3000
CMD ["java", "-jar", "/vendo/app.jar", "--server.port=$PORT"]
And I'm pushing my project using git push heroku master, and I get the error:
remote: Step 8/11 : RUN lein uberjar
remote: ---> Running in 07533c6b0e9c
remote: /bin/sh: lein: not found
remote: The command '/bin/sh -c lein uberjar' returned a non-zero code: 127
Suggesting that lein wasn't installed. The wget in that first RUN command is supposed to install lein. How do I fix this issue?
You need to add a RUN lein to run the self-install.
I'm trying to use pandas to write a csv to file in my flask app (wrapped with uwsgi) but I keep getting a permission denied error, despite adding uwsgi to my user-group, have I missed something?
docker buildfile:
FROM kennethreitz/pipenv as build
ADD . /app
WORKDIR /app
RUN pipenv install --deploy --system \
&& pipenv lock -r > requirements.txt \
&& pipenv run python setup.py bdist_wheel
FROM ubuntu:bionic
COPY --from=build /app/dist/*.whl .
ARG DEBIAN_FRONTEND=noninteractive
RUN set -xe \
&& apt-get update -q \
&& apt-get install -y -q \
python3-wheel \
python3-pip \
uwsgi-plugin-python3 \
&& python3 -m pip install *.whl \
&& apt-get remove -y python3-pip python3-wheel \
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -f *.whl \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /app \
&& useradd _uwsgi --no-create-home --user-group
USER _uwsgi
ENTRYPOINT ["/usr/bin/uwsgi", \
"--master", \
"--enable-threads", \
"--die-on-term", \
"--plugin", "python3"]
CMD ["--http-socket", "0.0.0.0:8000", \
"--processes", "4", \
"--chdir", "/app", \
"--check-static", "static", \
"--module", "server:app"]