clone private gitlab repo on docker file using ssh - docker

I created a Dockerfile to create an image for a container. I need to clone a private repo on this docker file
I follow this tutorial
https://vsupalov.com/better-docker-private-git-ssh/
I added this steps to my Dockerfile
RUN --mount=type=ssh
WORKDIR /
RUN git clone git#gitlab.<my private repo>.git
My sshkey on the host is
inls ~/.ssh/
id_ed25519 id_ed25519.pub known_hosts
I try to clone the private repo to the root of the container that will be build with this docker image
update
here is my final docker file
FROM python:3.8-bullseye
RUN apt-get update && \
apt-get install --yes --no-install-recommends \
openssh-client \
git \
&& apt-get clean
RUN mkdir -p -m 0600 ~/.ssh && \
ssh-keyscan -H gitlab.com ~/.ssh/known_hosts
RUN --mount=type=ssh \
git clone git#gitlab.<org>/<>repo.git
and I get this error
docker buildx build --ssh default .
[+] Building 0.6s (8/12)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 32B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/python:3.8-bullseye 0.0s
=> [1/8] FROM docker.io/library/python:3.8-bullseye 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 6.56kB 0.0s
=> CACHED [2/8] RUN apt-get update && apt-get install --yes --no-install-recommends openssh-client git && apt-get clean 0.0s
=> CACHED [3/8] RUN mkdir -p -m 0600 ~/.ssh && ssh-keyscan -H gitlab.com ~/.ssh/known_hosts 0.0s
=> ERROR [4/8] RUN --mount=type=ssh git clone git#git#gitlab.<org>/<>repo.git 0.5s
------
> [4/8] RUN --mount=type=ssh git clone git#git#gitlab.<org>/<>repo.git:
#0 0.299 Cloning into 'the-dock'...
#0 0.432 Host key verification failed.
#0 0.433 fatal: Could not read from remote repository.
#0 0.433
#0 0.433 Please make sure you have the correct access rights
#0 0.433 and the repository exists.
------
ERROR: failed to solve: executor failed running [/bin/sh -c git clone git#git#gitlab.<org>/<>repo.git]: exit code: 128

Related

laravel sail won't install or start. same goes with composer update

This question was migrated from Server Fault because it can be answered on Stack Overflow.
Migrated 5 days ago.
I've git cloned a project. my project from github.
the files are correct, checked them up.
On my pc I use sail and it works. however, it fails on my new station.
sail up (or build) raises this error:
[+] Running 0/1
⠿ laravel.test Warning 0.1s
[+] Building 76.5s (8/15)
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 32B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/ubuntu:22.04 0.8s
=> [internal] load build context 0.1s
=> => transferring context: 99B 0.0s
=> [ 1/11] FROM docker.io/library/ubuntu:22.04#sha256:27cxxxxxxxxxxxxxxxxxxxxxxxf3f928 0.0s
=> CACHED [ 2/11] WORKDIR /var/www/html 0.0s
=> CACHED [ 3/11] RUN ln -snf /usr/share/zoneinfo/UTC /etc/localtime && echo UTC > /etc/timezone 0.0s
=> ERROR [ 4/11] RUN apt-get update && apt-get install -y gnupg gosu curl ca-certificates zip unzip git sup 75.5s
------
> [ 4/11] RUN apt-get update && apt-get install -y gnupg gosu curl ca-certificates
zip unzip git supervisor sqlite3 libcap2-bin libpng-dev python2 dnsutils && curl -sS
'https://keyserver.ubuntu.com/pks/lookup?op=get&
search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | gpg --dearmor | tee /usr/share
/keyrings/ppa_ondrej_php.gpg > /dev/null && echo "deb [signed-by=/usr/share/keyrings/ppa_ondrej_php.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" >
/etc/apt/sources.list.d/ppa_ondrej_php.list && apt-get update && apt-get install -y php8.1-cli php8.1-dev
.................
Running composer update fails due to database connection error...
any idea?

Docker cross compile build context leads to `dockerfile.v0: unsupported frontend capability moby.buildkit.frontend.contexts`

I'm trying to cross compile a rust application for my raspberry pi (the compilation there is very slow).
For that I try to execute a Dockerfile with a build context somewhere else (because there are some certificates and other things, which are needed in the Docker image).
Dockerfile (./myapp/Dockerfile)
FROM rust
RUN apt-get update && apt-get install -y pkg-config libssl-dev build-essential cmake
WORKDIR /home/myapp
COPY --from=local ./myapp/. .
COPY --from=local ./mqtt-helper/ /home/mqtt-helper/
COPY --from=local ./mqtt-broker/config/certs/ca.crt ./certs/
COPY --from=local ./mqtt-broker/config/certs/mqtt-subscriber.key ./certs/
COPY --from=local ./mqtt-broker/config/certs/mqtt-subscriber.crt ./certs/
ENV TZ=Europe/Berlin
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN cargo install --path .
EXPOSE 8080
CMD ["myapp"]
Now I'm trying to run:
docker buildx build --platform linux/arm64 --build-context local=./ ./myapp/
But this call always leads into:
[+] Building 0.0s (2/2) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 32B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
ERROR: failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: unsupported frontend capability moby.buildkit.frontend.contexts
thank you

Issue with `multiarch-support` is not installable when building Docker image

My Dockerfile
FROM continuumio/miniconda3
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends g++ unixodbc-dev
# Copy environment.yml (if found) to a temp location so we update the environment.
COPY environment.yml /tmp/conda-tmp/
RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then /opt/conda/bin/conda env update -n base -f /tmp/conda-tmp/environment.yml; fi \
&& rm -rf /tmp/conda-tmp
RUN apt install -y gnupg curl
RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
RUN curl https://packages.microsoft.com/config/debian/10/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"' >> ~/.bashrc
RUN . ~/.bashrc
# optional: for unixODBC development headers
RUN apt-get install -y unixodbc-dev
WORKDIR /workspace
COPY . .
ENTRYPOINT ["/bin/bash"]
When I am trying to build the docker image using docker build -t my-simulator . I am getting the followings:
=> [internal] load build definition from Dockerfile 0.0s => => transferring dockerfile: 1.09kB 0.0s => [internal] load .dockerignore 0.0s => => transferring context: 34B 0.0s => [internal] load metadata for docker.io/continuumio/miniconda3:latest 1.1s => [auth] continuumio/miniconda3:pull token for registry-1.docker.io 0.0s => [internal] load build context 0.0s => => transferring context: 11.16kB 0.0s => [ 1/15] FROM docker.io/continuumio/miniconda3#sha256:977263e8d1e476972fddab1c75fe050dd3cd17626390e874448bd92721fd659b 0.0s => CACHED [ 2/15] RUN apt-get update && export DEBIAN_FRONTEND=noninteractive && apt-get -y install --no-install-recommends g++ unixodbc-dev 0.0s => CACHED [ 3/15] COPY environment.yml /tmp/conda-tmp/ 0.0s => CACHED [ 4/15] RUN if [ -f "/tmp/conda-tmp/environment.yml" ]; then /opt/conda/bin/conda env update -n base -f /tmp/conda-tmp/environment.yml; fi && rm -rf /tmp/conda- 0.0s => CACHED [ 5/15] RUN apt install -y gnupg curl 0.0s => CACHED [ 6/15] RUN curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - 0.0s => CACHED [ 7/15] RUN curl https://packages.microsoft.com/config/debian/10/prod.list > /etc/apt/sources.list.d/mssql-release.list 0.0s => CACHED [ 8/15] RUN apt-get update 0.0s => ERROR [ 9/15] RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17 0.8s ------
> [ 9/15] RUN ACCEPT_EULA=Y apt-get install -y msodbcsql17:
#14 0.313 Reading package lists...
#14 0.651 Building dependency tree...
#14 0.736 Reading state information...
#14 0.771 Some packages could not be installed. This may mean that you have
#14 0.771 requested an impossible situation or if you are using the unstable
#14 0.771 distribution that some required packages have not yet been created
#14 0.771 or been moved out of Incoming.
#14 0.771 The following information may help to resolve the situation:
#14 0.771
#14 0.771 The following packages have unmet dependencies:
#14 0.810 libodbc1 : PreDepends: multiarch-support but it is not installable
#14 0.810 odbcinst1debian2 : PreDepends: multiarch-support but it is not installable
#14 0.817 E: Unable to correct problems, you have held broken packages.
------
executor failed running [/bin/sh -c ACCEPT_EULA=Y apt-get install -y msodbcsql17]: exit code: 100
It seems the issue is multiarch-suppot being not installable. I have tried these solutions (#1 and #2) without success.

failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to do request: Head error when running docker build

I have following Dockerfile:
FROM alpine:latest
COPY . .
# C-CPP
RUN apk update \
&& apk add build-base \
&& apk add g++
# JAVA 8
RUN apk fetch openjdk8 \
&& apk add openjdk8
ENV JAVA_HOME=/usr/lib/jvm/java-1.8-openjdk
ENV PATH="$JAVA_HOME/bin:${PATH}"
# Python 3
RUN apk add python3 py3-pip \
&& apk add --upgrade bash
RUN ["chmod", "+x", "./run.sh"]
ENTRYPOINT [ "./run.sh" ]
When I hit command docker build -t dockerfile ., I get this error - what does it mean and how to fix it?
> [+] Building 28.2s (3/3) FINISHED => [internal] load build definition
> from Dockerfile 1.3s
> => => transferring dockerfile: 32B 0.2s
=> [internal] load .dockerignore 1.6s
=> => transferring context: 2B 0.1s
=> ERROR [internal] load metadata for docker.io/library/alpine:latest 26.5s
> ------
> > [internal] load metadata for docker.io/library/alpine:latest:
> ------
failed to solve with frontend dockerfile.v0: failed to create LLB definition: failed to do request: Head
> "https://registry-1.docker.io/v2/library/alpine/manifests/latest": di
al tcp 52.200.78.26:443: i/o timeout
This is clearly network timeout issue. There is no syntax error, shared dockerfile works fine.
How to verify network issue:
if you have curl tool
curl -v https://registry-1.docker.io/v2/library/alpine/manifests/latest
Output from curl
or just type in browswer
https://registry-1.docker.io/v2/library/alpine/manifests/latest
I fixed it by stopping buildx: docker buildx stop

Docker build fails with 'secret pip not found: not found' error

I am trying to build a docker image but getting
secret pip not found: not found
Any ideas on this?
Dockerfile:
FROM <jfrog dockerfile package>
SHELL ["/bin/bash", "-c"]
RUN apt-get update \
&& apt-get -y install chromium chromium-driver
COPY requirments.txt
RUN pip install -r requirments.txt
USER nobody
CMD robot ./smoketests-nonprod.robot \
&& robot ./smoketests-prod.robot
The log is as follows:
$ docker build -t robottests .
[+] Building 1.6s (18/25)
=> [internal] load build definition from Dockerfile 0.1s
=> => transferring dockerfile: 39B 0.0s
=> [internal] load .dockerignore 0.1s
=> => transferring context: 35B 0.0s
=> resolve image config for my-company-docker-virtual.jfrog.io/docker/dockerfile:1.2 0.0s
=> CACHED docker-image://my-company-docker-virtual.jfrog.io/docker/dockerfile:1.2 0.0s
=> [internal] load metadata for my-company-docker-virtual.jfrog.io/node:14-buster-slim 0.0s
=> [internal] load metadata for my-company-docker-virtual.jfrog.io/python:3-slim 0.0s
=> [base 1/7] FROM my-company-docker-virtual.jfrog.io/python:3-slim 0.0s
=> [client 1/6] FROM my-company-docker-virtual.jfrog.io/node:14-buster-slim 0.0s
=> [internal] load build context 0.1s
=> => transferring context: 5.25kB 0.0s
=> CACHED [base 2/7] RUN echo 'APT { Default-Release "stable"; };' >/etc/apt/apt.conf && echo deb http://deb.debian.org/debian testing main >>/etc/apt/sources.list 0.0s
=> CACHED [base 3/7] RUN --mount=type=cache,target=/var/cache/apt --mount=type=secret,id=sources.list,target=/etc/apt/sources.list,required=true apt update && apt -y install libcap2-bin/testing 0.0s
=> CACHED [base 4/7] RUN ["/sbin/setcap", "cap_net_bind_service,cap_setpcap+p", "/sbin/capsh"] 0.0s
=> CACHED [base 5/7] WORKDIR /project 0.0s
=> CACHED [base 6/7] COPY pyproject.toml setup.* . 0.0s
=> CACHED [client 2/6] WORKDIR /client 0.0s
=> CACHED [client 3/6] COPY package*.json . 0.0s
=> ERROR [base 7/7] RUN --mount=type=cache,target=/root/.cache --mount=type=secret,id=pip,target=/etc/pip.conf,required=true mkdir -p src && pip install -U pip wheel && pip install . && pip unin 0.1s
=> CANCELED [client 4/6] RUN --mount=type=secret,id=npmrc,target=/usr/local/etc/npmrc,required=true --mount=type=bind,source=.npmrc,target=/root/.npmrc --mount=type=cache,target=/root/.npm npm c 0.2s
------
> [base 7/7] RUN --mount=type=cache,target=/root/.cache --mount=type=secret,id=pip,target=/etc/pip.conf,required=true mkdir -p src && pip install -U pip wheel && pip install . && pip uninstall -y $(./setup.py --name):
------
secret pip not found: not found
Any help would be appreciated
This is using the relatively new --secret option which allows you to mount secrets at build time
The general way you utilize it is you have a secret file outside and assign it an id
in your case, you'd have a pip.conf file somewhere and specify it in your build command:
docker build --secret id=pip,src=pip.conf -t robottests .
this will make the pip.conf available during the build, but not part of your image (presumably because it contains authentication secrets for accessing your internal pypi)
Maybe I'm wrong, but for me you do not show the Dockerfile corresponding to the logs. Or there are some missing parts which could have been helpful.
I'd expect to view something like that in your Dockerfile which is in error :
RUN ["/sbin/setcap", "cap_net_bind_service,cap_setpcap+p", "/sbin/capsh"]
WORKDIR /project
COPY pyproject.toml setup.* .
WORKDIR /client
RUN --mount=type=cache,target=/root/.cache --mount=type=secret,id=pip,target=/etc/pip.conf,required=true mkdir -p src && pip install -U pip wheel && pip install . && pip unin...
Because in this last line, there is the part that fails :
--mount=type=secret,id=pip,target=/etc/pip.conf,required=true
And with the link provided by Anthony Sottile, or this link I think you can be able to find out what is wrong in your command.

Resources