Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can't build image #12

Open
Boklazhenko opened this issue Jan 8, 2020 · 5 comments
Open

can't build image #12

Boklazhenko opened this issue Jan 8, 2020 · 5 comments

Comments

@Boklazhenko
Copy link

cmd :
docker build -t identijenk .

ouput:
Sending build context to Docker daemon 2.56kB
Step 1/8 : FROM jenkins:1.609.3
---> 60d2fc1c3854
Step 2/8 : USER root
---> Using cache
---> 58d5549c8a56
Step 3/8 : RUN echo "deb http://apt.dockerproject.org/repo debian-jessie main" > /etc/apt/sources.list.d/docker.list && apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D && apt-get update && apt-get install -y apt-transport-https && apt-get install -y sudo && apt-get install -y docker-engine && rm -rf /var/lib/apt/lists/*
---> Running in 15793fbb78f2
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.9vhhqM49cT --no-auto-check-trustdb --trust-model always --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-jessie-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-jessie-security-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-jessie-stable.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-squeeze-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-squeeze-stable.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-wheezy-automatic.gpg --keyring /etc/apt/trusted.gpg.d/debian-archive-wheezy-stable.gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
gpg: requesting key 2C52609D from hkp server p80.pool.sks-keyservers.net
gpg: key 2C52609D: public key "Docker Release Tool (releasedocker) [email protected]" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
Ign http://httpredir.debian.org jessie InRelease
Get:1 http://apt.dockerproject.org debian-jessie InRelease [48.7 kB]
Get:2 http://httpredir.debian.org jessie-updates InRelease [16.3 kB]
Ign http://httpredir.debian.org jessie-backports InRelease
Get:3 http://httpredir.debian.org jessie Release.gpg [1652 B]
Ign http://httpredir.debian.org jessie-backports Release.gpg
Get:4 http://httpredir.debian.org jessie Release [77.3 kB]
Get:5 http://security.debian.org jessie/updates InRelease [44.9 kB]
Get:6 http://httpredir.debian.org jessie-updates/main amd64 Packages [20 B]
Ign http://httpredir.debian.org jessie-backports Release
Get:7 http://httpredir.debian.org jessie/main amd64 Packages [9098 kB]
Get:8 http://apt.dockerproject.org debian-jessie/main amd64 Packages [7366 B]
Get:9 http://security.debian.org jessie/updates/main amd64 Packages [922 kB]
Err http://httpredir.debian.org jessie-backports/main amd64 Packages

Err http://httpredir.debian.org jessie-backports/main amd64 Packages

Err http://httpredir.debian.org jessie-backports/main amd64 Packages

Err http://httpredir.debian.org jessie-backports/main amd64 Packages
404 Not Found
Fetched 10.2 MB in 8s (1266 kB/s)
W: There is no public key available for the following key IDs:
AA8E81B4331F7F50
W: Failed to fetch http://httpredir.debian.org/debian/dists/jessie-backports/main/binary-amd64/Packages 404 Not Found

E: Some index files failed to download. They have been ignored, or old ones used instead.
The command '/bin/sh -c echo "deb http://apt.dockerproject.org/repo debian-jessie main" > /etc/apt/sources.list.d/docker.list && apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D && apt-get update && apt-get install -y apt-transport-https && apt-get install -y sudo && apt-get install -y docker-engine && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 100

@avuskov
Copy link

avuskov commented Apr 14, 2020

I haven't finished the chapter yet, but I modified the Dockerfile and it helped me to pass the first test (docker run -v /var/run/docker.sock:/var/run/docker.sock identijenk sudo docker ps):

FROM jenkins:2.60.3
USER root

RUN apt-get update
&& apt-get install -y
apt-transport-https
ca-certificates
curl
gnupg-agent
software-properties-common
sudo
&& curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
&& apt-get update
&& apt-get install -y docker-ce
&& rm -rf /var/lib/apt/lists/*
RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers

@avuskov
Copy link

avuskov commented Apr 21, 2020

I've ended the chapter with this Dockerfile:

FROM jenkins/jenkins:lts
USER root

RUN apt-get update \
      && apt-get install -y \
         apt-transport-https \
         ca-certificates \
         curl \
         gnupg-agent \
         software-properties-common \
         sudo \
      && curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - \
      && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" \
      && apt-get update \
      && apt-get install -y docker-ce \
      && rm -rf /var/lib/apt/lists/*

RUN curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose; chmod +x /usr/local/bin/docker-compose

RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers

USER jenkins
COPY plugins.txt /usr/share/jenkins/plugins.txt
RUN /usr/local/bin/plugins.sh /usr/share/jenkins/plugins.txt

@Tobias-Pe
Copy link

Tobias-Pe commented Aug 9, 2021

The in the book described way to install plugins is deprecated.
Instead of running the /usr/local/bin/plugins.sh script, one should now use jenkins-plugin-cli.
To complement avuskov Dockerfile, following his version updated:

FROM jenkins/jenkins:lts
USER root

RUN apt-get update \
      && apt-get install -y \
         apt-transport-https \
         ca-certificates \
         curl \
         gnupg-agent \
         software-properties-common \
         sudo \
      && curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add - \
      && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" \
      && apt-get update \
      && apt-get install -y docker-ce \
      && rm -rf /var/lib/apt/lists/*

RUN curl -L https://github.com/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose; chmod +x /usr/local/bin/docker-compose

RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers

USER jenkins
COPY plugins.txt /usr/share/jenkins/plugins.txt
RUN jenkins-plugin-cli -f /usr/share/jenkins/plugins.txt

Documenting it in this issue for others who encounter this problem ;)

@pliniusblah
Copy link

pliniusblah commented Jan 26, 2023

An alternative to use a similar jenkins image like in the book.

FROM jenkins:1.651.3-alpine

ENV JENKINS_UC_DOWNLOAD 'http://ftp-nyc.osuosl.org/pub/jenkins'

USER root

RUN apk update
RUN apk add curl \
    openssl \
    ca-certificates \
    docker

RUN apk add --no-cache gnupg \
    && apk add --no-cache unzip \
    && apk add sudo \
    && apk add libltdl

RUN echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers.d/jenkins \
    && chmod 0440 /etc/sudoers.d/jenkins \
    && echo "jenkins ALL=NOPASSWD: ALL" >> /etc/sudoers \
    && rm -rf /var/lib/apt/lists/*

RUN sudo curl -L https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

RUN sudo chmod +x /usr/local/bin/docker-compose \
    && sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

USER jenkins
COPY plugins.txt /usr/share/jenkins/plugins.txt
RUN /usr/local/bin/plugins.sh /usr/share/jenkins/plugins.txt

jenkins.yml

services:
  identidock:
    build: .
    expose:
      - "9090"
    environment:
      ENV: PROD
    links:
      - dnmonster
      - redis

  dnmonster:
    image: amouat/dnmonster:1.0

  redis:
    image: redis:3.0

@devaals
Copy link

devaals commented May 24, 2023

Actual for me jenkins_shell:

#Default compose args
COMPOSE_ARGS=" -f jenkins.yml -p jenkins "
USER_DOCKER_HUB="some_user"
PASS_DOCKER_HUB="some_password"


#Make sure old containers are gone
sudo docker-compose $COMPOSE_ARGS stop
sudo docker-compose $COMPOSE_ARGS rm --force -v

#build the system
sudo docker-compose $COMPOSE_ARGS build --no-cache
sudo docker-compose $COMPOSE_ARGS up -d

#Run unit tests
sudo docker-compose $COMPOSE_ARGS run --no-deps --rm -e ENV=UNIT identidock
ERR=$?

#Run system test if unit tests passed
if [ $ERR -eq 0 ]; then
  IP=$(sudo docker inspect -f "{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}" jenkins-identidock-1)
  CODE=$(curl -sL -w "%{http_code}" $IP:9090/monster/bla -o /dev/null) || true
  if [ $CODE -ne 200 ]; then
    echo "Test passed - Tagging"
    HASH=$(git rev-parse --short HEAD)
    sudo docker tag -f jenkins-identidock $USER_DOCKER_HUB/identidock:$HASH
    sudo docker tag -f jenkins-identidock $USER_DOCKER_HUB/identidock:newest
    echo "Pushing"
    sudo docker login -e [email protected] -u $USER_DOCKER_HUB -p $PASS_DOCKER_HUB
    sudo docker push $USER_DOCKER_HUB/identidock:$HASH
    sudo docker push $USER_DOCKER_HUB/identidock:newest
  else
    echo "Site returned " $CODE
    ERR=1
  fi
fi

#Pull down the system
sudo docker-compose $COMPOSE_ARGS stop
sudo docker-compose $COMPOSE_ARGS rm --force -v

return $ERR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants