I have the following docker compose configuration:
version: '3.3'
services:
jenkins:
image: jenkins-ansible
build: ansible
restart: on-failure
privileged: true
user: root
ports:
- 8080:8080
- 5000:5000
container_name: jenkins
volumes:
- /home/juliano/workspace/docker-projects/jenkins/volume/:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/local/bin/docker:/usr/local/bin/docker
jenkins-agent-1:
build:
context: jenkins-agent
restart: on-failure
expose:
- "22"
container_name: jenkins-agent-1
environment:
- JENKINS_AGENT_SSH_PUBKEY=ssh-rsa omitted
- JAVA_HOME=/opt/java/openjdk/bin/java
depends_on:
- jenkins
volumes:
- /home/juliano/workspace/docker-projects/jenkins/volume/:/var/jenkins_home
jenkins-agent-2:
# image: jenkins/ssh-agent:jdk11
build:
context: jenkins-agent
restart: on-failure
expose:
- "22"
container_name: jenkins-agent-2
environment:
- JENKINS_AGENT_SSH_PUBKEY=ssh-rsa omitted
- JAVA_HOME=/opt/java/openjdk/bin/java
depends_on:
- jenkins
volumes:
- /home/juliano/workspace/docker-projects/jenkins/volume/:/var/jenkins_home
remote_host:
container_name: remote-host
image: remote-host
build:
context: ubuntu18.04
And I'm receiving the following error message:
+ env
+ [[ ssh-rsa omitted == ssh-* ]]
+ write_key 'ssh-rsa omitted'
+ local ID_GROUP
++ stat -c %U:%G /home/jenkins
+ ID_GROUP=jenkins:jenkins
+ mkdir -p /home/jenkins/.ssh
+ echo 'ssh-rsa omitted'
+ chown -Rf jenkins:jenkins /home/jenkins/.ssh
+ chmod 0700 -R /home/jenkins/.ssh
+ [[ '' == ssh-* ]]
+ env
+ grep _
/usr/local/bin/setup-sshd: line 54: /etc/environment: Permission denied
The jenkins-agent dockerfile is:
FROM jenkins/ssh-agent
USER root
RUN apt-get update && apt-get install python3 -y
RUN apt-get install curl -y
RUN apt-get install python3-distutils -y
RUN curl -O https://bootstrap.pypa.io/get-pip.py && \
python3 get-pip.py && \
pip install ansible --upgrade
USER jenkins
Previously, I was using jenkins/ssh-agent:jdk11 to build the agents and it was working well. Then I unsuccessfully tried to install Ansible into the agents through the jenkins-agent Dockerfile (receiving the aforementioned error). Now, even if I change jenkins-agent to jenkins/ssh-agent:jdk11, it is incurring the same problem.
Anyone could kindly help me, please?
I changed the jenkins-agent/Dockerfile and removed USER root and USER jenkins.
Now it is working.
Related
I use the Docker environment with the Symfony framework. I created my own Dockerfile and my own docker-compose.yml file.
The problem is that the 'compose install' command does not run when I run the 'docker compose up' command.
Here is the code of my dockerfile :
ARG PHP_VERSION=8.1
FROM php:${PHP_VERSION}-fpm
RUN apt-get update && apt-get install -y
# Install modules
RUN apt-get install -y --no-install-recommends \
git \
zlib1g-dev \
libxml2-dev \
libzip-dev \
libpq-dev \
nano \
&& docker-php-ext-install \
zip \
intl \
pdo \
mysqli \
pdo_mysql \
opcache
# Install Composer
RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
# Install Symfony CLI
RUN curl -sS https://get.symfony.com/cli/installer | bash
RUN mv /root/.symfony/bin/symfony /usr/local/bin/symfony
# Copy the application files
COPY . /var/www/html
# Install dependencies from composer.json
RUN composer install
# Set the default directory inside the container
WORKDIR /var/www/html
Here is the code of my yml file:
version: '3.8'
networks:
myapp:
services:
db:
container_name: ${APP_NAME}-db
image: 'mariadb:latest'
restart: always
ports:
- 3306:3306
volumes:
- './.docker/mysql:/var/lib/mysql'
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASS}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASS}
MYSQL_DATABASE: ${MYSQL_DB}
networks:
- myapp
php:
container_name: ${APP_NAME}-php
build: ./docker/php
volumes:
- './:/var/www/html'
environment:
- APP_ENV=${APP_ENV}
- APP_SECRET=${APP_SECRET}
depends_on:
- db
networks:
- myapp
nginx:
container_name: ${APP_NAME}-nginx
image: 'nginx:latest'
ports:
- 8080:80
#- 8443:443 # if https config
expose:
- 80
volumes:
- ./:/var/www/html
- ./docker/nginx/conf.d:/etc/nginx/conf.d
depends_on:
- php
networks:
- myapp
phpmyadmin:
image: 'phpmyadmin/phpmyadmin:latest'
container_name: ${APP_NAME}-phpmyadmin
ports:
- 8000:80
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASS}
networks:
- myapp
Do you know where the problem is? I copy well the root files (where is my composer.json file) to the container folder (/var/www/html). My files are well present when I do the command 'docker-compose exec php /bin/bash' then 'ls'.
I have the following structure:
- MY-PROJECT
> docker/
> nginx/
> php
> Dockerfile
.env
composer.json
docker-compose.yml
I tried several methods, including moving the commands into the file or putting the 'compose install' command in the .yml file, but I don't think this is the solution.
I would suggest that you move your Dockerfile to the root directory of your project and set the context to .
php:
container_name: ${APP_NAME}-php
build: .
volumes:
- './:/var/www/html'
environment:
- APP_ENV=${APP_ENV}
- APP_SECRET=${APP_SECRET}
depends_on:
- db
networks:
- myapp
You need also to change some order inside your Dockerfile and for Symfony cli you need to change it:
RUN mv /root/.symfony5/bin/symfony /usr/local/bin/symfony
Last, if you are new on this i would suggest that you use the documentation from Symfony:
https://symfony.com/doc/current/setup/docker.html
You can then adapt it on your need and add phpMyAdmin etc...
This error message appears to 3 images in composed docker container.
exec /usr/bin/entrypoint.sh: no such file or directory
All images related to Ruby execution of services
Sidekiq, Webpack runned by Ruby executable and Web(rails) services
I have tried change every execution to run loading de Gemfile environment using bundle exec, but nothing worked.
Dockerfile
FROM ruby:2.6.6
RUN apt-get update -qq \
&& apt-get install -y curl build-essential libpq-dev postgresql \
nodejs postgresql-client &&\
curl -sL https://deb.nodesource.com/setup_14.x | bash - && \
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - && \
echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list && \
apt-get update && apt-get install -y nodejs yarn
ADD . /app
WORKDIR /app
RUN gem install bundler:2.3.22
RUN bundle install
RUN yarn install --check-files
RUN gem install foreman
COPY entrypoint.sh /usr/bin/
RUN chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
EXPOSE 80
CMD ["bash"]
docker-compose.yml
version: '3.3'
services:
db:
image: postgres
ports:
- 5423:5432
volumes:
- ./tmp/db:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: *****
redis:
image: redis
ports:
- "6379:6379"
volumes:
- 'redis:/data'
depends_on:
- db
webpack:
build: .
command: sh -c 'rm -rf public/packs/* || true && bin/webpack-dev-server --host 0.0.0.0 --port 3035 -w'
volumes:
- .:/app
- /app/node_modules
ports:
- "3035:3035"
depends_on:
- db
web:
build: .
command: bash -c "rm -f tmp/pids/server.pid && rails s -b 0.0.0.0 -p 80"
volumes:
- .:/app
ports:
- "80:80"
depends_on:
- db
- redis
- webpack
- chrome
env_file: .env_docker
environment:
RAILS_ENV: development
RAILS_MAX_THREADS: 5
sidekiq:
build: .
command: bundle exec sidekiq -C config/sidekiq.yml
volumes:
- .:/app
depends_on:
- db
- redis
env_file: .env_docker
environment:
RAILS_MAX_THREADS: 5
chrome:
image: selenium/standalone-chrome
ports:
- "4444:4444"
volumes:
- /dev/shm:/dev/shm
depends_on:
- db
- redis
- webpack
- sidekiq
volumes:
redis:
postgres:
Equal to entrypoint.sh exec: #: not found but not resolved
I really want to change my Debian development OS to Windows and work only with containers, not looking to Linux or WSL alternatives
I am running sudo docker compose -f docker-compose.development.yml up --build to build my project container
but I'm getting this error:
failed to solve: executor failed running [/bin/sh -c curl -fLo install.sh https://raw.githubusercontent.com/cosmtrek/air/master/install.sh && chmod +x install.sh && sh install.sh && cp ./bin/air /bin/air]: exit code: 6
here's my docker file:
FROM golang:1.17.5-stretch
ARG GIT_DEPLOY_TOKEN_USER
ARG GIT_DEPLOY_TOKEN_PASSWORD
RUN apt-get update && apt-get upgrade -y && \
apt-get install -y git
# private gitlab package credentials
RUN go env -w GOPRIVATE=gitlab.com
RUN touch ~/.netrc
RUN chmod 600 ~/.netrc
RUN echo "machine gitlab.com login ${GIT_DEPLOY_TOKEN_USER} password ${GIT_DEPLOY_TOKEN_PASSWORD}" >> ~/.netrc
WORKDIR /app
# RUN go mod download
# # COPY the source code as the last step
# COPY . .
RUN curl -fLo install.sh https://raw.githubusercontent.com/cosmtrek/air/master/install.sh \
&& chmod +x install.sh && sh install.sh && cp ./bin/air /bin/air
RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.45.2
CMD air
and this is my docker-compose.development.yml file:
services:
graphql:
container_name: chimp-bff-development
build:
context: .
dockerfile: dev.Dockerfile
args:
GIT_DEPLOY_TOKEN_USER: $GIT_DEPLOY_TOKEN_USER
GIT_DEPLOY_TOKEN_PASSWORD: $GIT_DEPLOY_TOKEN_PASSWORD
ports:
- "$PORT:$PORT"
depends_on:
- redis
volumes:
- ./:/app
networks:
- chimpbff-bridge
redis:
hostname: $RDB_HOST_NAME
container_name: chimpbff_redis
build:
context: ./Docker/redis
args:
- APQ_RDB_USERNAME=$APQ_RDB_USERNAME
- APQ_RBD_PASSWORD=$APQ_RBD_PASSWORD
- RBD_PORT=$RBD_PORT
expose:
- $RBD_PORT
volumes:
- ./Docker/data/redis:/data
sysctls:
- net.core.somaxconn=511
# restart: always
logging:
driver: "json-file"
options:
max-file: "5"
max-size: "10m"
networks:
- chimpbff-bridge
networks:
chimpbff-bridge:
driver: bridge
driver_opts:
com.docker.network.bridge.name: chimp-bridge
what does exit code 6 means? and what should I do to fix it?
After updating Docker (to newest 19.03.13) and postgres (from 12 to 13) my gitlab pipeline now fails - without an traces. It is triggered but pull fails after 1second, without any traces.
Gitlab runner is running, and is not shared with other projects.
Docker is connected to registry and can build and push updated images.
Have tried to clone to new repo and redo gitlab runner registration. Haven't found any other similar issues posted here. Have run out of ideas of what to try.
Any help will be much appreciated !
The pipeline output (ie no output)
My .gitlab-ci.yml
stages:
- pull
- build
- lint
- push
- cleanup
- deploy
before_script:
- docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" "$CI_REGISTRY"
pull:
stage: pull
allow_failure: true
script:
- docker pull "$CI_REGISTRY_IMAGE":latest
build:
stage: build
script:
- docker build --tag="$CI_PIPELINE_ID":"$CI_COMMIT_REF_NAME" --cache-from="$CI_REGISTRY_IMAGE":latest .
lint:
stage: lint
script:
- docker-compose -p "$CI_PIPELINE_ID" -f docker-compose.ci.yml run app ls
- docker-compose -p "$CI_PIPELINE_ID" -f docker-compose.ci.yml run app cat tox.ini
- export CI_PIPELINE_ID=$CI_PIPELINE_ID
- export CI_COMMIT_REF_NAME=$CI_COMMIT_REF_NAME
- docker-compose -p "$CI_PIPELINE_ID" -f docker-compose.ci.yml run app flake8 .
push image:
stage: push
only:
- master
- tags
script:
- docker tag "$CI_PIPELINE_ID":"$CI_COMMIT_REF_NAME" "$CI_REGISTRY_IMAGE":"$CI_COMMIT_REF_NAME"
- docker push "$CI_REGISTRY_IMAGE":"$CI_COMMIT_REF_NAME"
push latest:
stage: push
script:
- docker tag "$CI_PIPELINE_ID":"$CI_COMMIT_REF_NAME" "$CI_REGISTRY_IMAGE":latest
- docker push "$CI_REGISTRY_IMAGE":latest
cleanup:
stage: cleanup
when: always
script:
- docker rmi -f "$CI_PIPELINE_ID":"$CI_COMMIT_REF_NAME"
- docker-compose -p "$CI_PIPELINE_ID" -f docker-compose.ci.yml down --remove-orphans
deploy:
stage: deploy
when: manual
only:
- master
- tags
script:
- docker-compose -f docker-compose.deploy.yml pull
- docker-compose -f docker-compose.deploy.yml down --remove-orphans
- docker-compose -f docker-compose.deploy.yml up -d
My docker-compose.ci.yml
version: "3"
services:
app:
image: "${CI_PIPELINE_ID}:${CI_COMMIT_REF_NAME}"
My docker-compose.yml
version: "3"
services:
backend:
image: registry.gitlab.com/my_account/my_project:latest
env_file:
- dev.env
ports:
- "8000:8000"
- "4777:22"
volumes:
- ./backend:/backend
command: "/usr/sbin/sshd -D"
depends_on:
- postgres
postgres:
image: postgres:latest
restart: always
env_file:
- dev.env
ports:
- "5432:5432"
volumes:
- postgres:/var/lib/postgresql/data
volumes:
postgres:
static-files:
media-files:
My docker-compose.deploy.yml
version: "3"
services:
backend:
image: registry.gitlab.com/my_account/my_project:latest
command: "sh /scripts/run.sh"
env_file:
- dev.env
depends_on:
- postgres
volumes:
- media-files:/media-files
- static-files:/static-files
- frontend:/frontend-build
postgres:
image: postgres:latest
env_file:
- dev.env
ports:
- "5432:5432"
volumes:
- postgres:/var/lib/postgresql/data
nginx:
image: nginx:latest
ports:
- "80:80"
- "443:443"
volumes:
- ./nginx:/etc/nginx/conf.d
- /etc/letsencrypt:/etc/letsencrypt
- static-files:/static-files/
- media-files:/media-files/
- frontend:/frontend
volumes:
postgres:
static-files:
media-files:
frontend:
My Dockerfile
FROM continuumio/miniconda:latest
ENV LANG=C.UTF-8 LC_ALL=C.UTF-8
RUN apt-get update && apt-get upgrade -y && apt-get install -qqy \
wget \
bzip2 \
graphviz \
libssl-dev \
openssh-server
RUN apt-get update && apt-get install -y curl
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
RUN apt-get update && apt-get install -y nodejs
RUN mkdir /var/run/sshd
RUN echo 'root:screencast' | chpasswd
RUN sed -i '/PermitRootLogin/c\PermitRootLogin yes' /etc/ssh/sshd_config
RUN sed 's#session\s*required\s*pam_loginuid.so#session optional pam_loginuid.so#g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
RUN echo "export VISIBLE=now" >> /etc/profile
RUN mkdir -p /backend
COPY ./backend/requirements.yml /backend/requirements.yml
RUN /opt/conda/bin/conda env create -f /backend/requirements.yml
ENV PATH /opt/conda/envs/backend/bin:$PATH
ENV PYTHONDONTWRITEBYTECODE 1
RUN echo "source activate backend" >~/.bashrc
COPY ./scripts /scripts
RUN chmod +x ./scripts*
COPY ./backend /backend
COPY ./frontend /frontend
WORKDIR /frontend
RUN npm install && npm run build
WORKDIR /backend
I'm trying to setup docker for a existing QuorraJs application.
(https://quorrajs.org/docs/v1/preface/quickstart.html) however i'm having issues when trying to run docker-compose build.
I am still quite new to docker, not sure what i am doing wrong.
docker file
FROM node:latest
MAINTAINER Erkan Demir <erkan.demir#peopleplan.com.au>
#Add everything in the current directory to our image
ADD . /var/www
RUN cd /var/www; \
npm install \
npm install -g quorra-cli \
EXPOSE 3000:3000
CMD["quorra ride"]
docker-compose.yml
version: '2'
services:
web:
container_name: quorra-web
build: .
ports:
- '3000:3000'
volumes:
- .:/var/www
links:
- db
depends_on:
- db
db:
container_name: quorra-db
image: mysql
ports:
- '3000:3000'
volumes:
- /var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: Petbarn_DB
MYSQL_USER: root
MYSQL_PASSWORD: password
Apparently there are some things wrong in your Dockerfile, try running it as follows:
FROM node:latest
MAINTAINER Erkan Demir <erkan.demir#peopleplan.com.au>
#Add everything in the current directory to our image
ADD . /var/www
RUN cd /var/www/ && \
npm install && \
npm install -g quorra-cli
EXPOSE 3000
CMD['quorra', 'ride']
Try adding && and remove last \ in your Dockerfile:
...
RUN cd /var/www; \
npm install \
&& npm install -g quorra-cli
...