I am trying to make sure my docker work or not in my Jenkins,
I am running Jenkins in docker and it was running but when I check in Jenkins Pipeline, it said docker: not found
here is my docker-compose.yml
version: '3.7'
services:
jenkins:
image: jenkinsci/blueocean:latest
user: root
privileged: true
restart: always
ports:
- 8080:8080
volumes:
- ./jenkins_home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
registry:
image: registry
container_name: registry
restart: always
ports:
- 5000:5000
then I run sudo docker-compose up -d
then the Jenkins is running,
can I know why the docker not found ? is my docker-compose wrong ?
You do not need to bind - /usr/bin/docker:/usr/bin/docker, as - /var/run/docker.sock:/var/run/docker.sock is engough to interact with host docker. you should not bind executable with docker container
remove this from the compose file and it should work.
- /usr/bin/docker:/usr/bin/docker
Related
i want to upgrade my nexus docker container from sonatype/nexus3:3.18.0 to sonatype/nexus3:3.47.1
my docker-compose is
nexus:
image: sonatype/nexus3:3.18.0
restart: always
environment:
NEXUS_CONTEXT: nexus
INSTALL4J_ADD_VM_PARAMS: "-Xms4703m -Xmx4703m -XX:MaxDirectMemorySize=4703m -Djava.util.prefs.userRoot=/nexus-data/javaprefs"
ports:
- 8082:8082
- 8083:8083
- 8084:8084
- 8085:8085
volumes:
- ${DOCKER_VOLUME_BASE:?base}/Nexus/data:/nexus-data
networks:
default:
do I need upgrade step by step? like gitlab docker container? or just change docker-compose to new version?
I have just started to learn Docker.
I have tried to run jenkins in my docker.
I have tried the commands:
docker run jenkins ,
docker run jenkins:latest
But showing the error in the docker interactive shell:
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon: manifest for jenkins:latest not found: manifest unknown: manifest unknown.
You can run the container by using the command
docker run -p 8080:8080 -p 50000:50000 jenkins/jenkins:lts
The documentation page is pretty good.
I would use a docker-compose file to
mount a volume for home to make it persistent
(in order to look into the build workspace you need to attach another container to it)
control the version programmatically
add docker client or other utilities installed later
add 'fixed' agents
docker compose file:
version: '3.5'
services:
jenkins-server:
build: ./JenkinsServer
container_name: jenkins
restart: always
environment:
JAVA_OPTS: "-Xmx1024m"
ports:
- "50000:50000"
- "8080:8080"
networks:
jenkins:
aliases:
- jenkins
volumes:
- jenkins-data:/var/jenkins_home
networks:
jenkins:
external: true
volumes:
jenkins-data:
external: true
dockerfile for server:
FROM jenkins/jenkins:2.263.2-lts
USER root
I want to bind my docker binaries and docker.sock to my docker jenkins container so that i will be able to use docker inside jenkins. This is my docker-compose.yml
version: "2"
services:
traefik:
image: traefik
restart: always
container_name: "${PROJECT_NAME}_traefik"
command: --api --docker
ports:
- '80:80'
- '443:443'
volumes:
- ./traefik.toml:/traefik.toml
- ./acme.json:/acme.json
labels:
- "traefik.frontend.rule=Host:${PROJECT_BASE_URL}"
jenkins:
#image: jenkins/jenkins
build: .
container_name: "${PROJECT_NAME}_jenkins"
environment:
- "JAVA_OPTS=-Dmail.smtp.starttls.enable=true"
ports:
- '50000:50000'
volumes:
- ./jenkins_home:/var/jenkins_home
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/bin/docker
labels:
- "traefik.frontend.rule=Host:${PROJECT_BASE_URL}"
Is there something I missed? I am not using sudo when running docker-compose start.
You need to make the jenkins container privileged to access a device. By default this is turned off, probably for security.
See https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities for more details, it even gives the example of running the docker daemon.
In your docker compose file add privileged: true to your jenkins service
I run this command manually:
$ docker run -it --rm \
--network app-tier \
bitnami/cassandra:latest cqlsh --username cassandra --password cassandra cassandra-server
But I don't know how to convert it to a docker compose file, specially the container's custom properties such as --username and --password.
What should I write in a docker-compose.yaml file to obtain the same result?
Thanks
Here is a sample of how others have done it. http://abiasforaction.net/apache-cassandra-cluster-docker/
Running the command below
command:
Setting arg's below
environment:
Remember just because you can doesn't mean you should.. Compose is not always the best way to launch something. Often it can be the lazy way.
If your running this as a service id suggest building the dockerfile to start and then creating systemd/init scripts to rm/relaunch it.
an example cassandra docker-compose.yml might be
version: '2'
services:
cassandra:
image: 'bitnami/cassandra:latest'
ports:
- '7000:7000'
- '7001:7001'
- '9042:9042'
- '9160:9160'
volumes:
- 'cassandra_data:/bitnami'
volumes:
cassandra_data:
driver: local
although this will not provide you with your commandline arguments but start it with the default CMD or ENTRYPOINT.
As you are actually running another command then the default you might not want to do this with docker-compose. Or you can create a new Docker image with this command as the default and provide the username and password as ENV's
e.g. something like this (untested)
FROM bitnami/cassandra:latest
ENV USER=cassandra
ENV PASSWORD=password
CMD ["cqlsh", "--username", "$USER", "--password", "$PASSWORD", "cassandra-server"]
and you can build it
docker build -t mycassandra .
and run it with something like:
docker run -it -e "USER=foo" -e "PASSWORD=bar" mycassandra
or in docker-compose
services:
cassandra:
image: 'mycassandra'
ports:
- '7000:7000'
- '7001:7001'
- '9042:9042'
- '9160:9160'
environment:
USER:user
PASSWORD:pass
volumes:
- 'cassandra_data:/bitnami'
volumes:
cassandra_data:
driver: local
You might looking for something like the following. Not sure if it is going to help you....
version: '3'
services:
my_app:
image: bitnami/cassandra:latest
command: /bin/sh -c cqlsh --username cassandra --password cassandra cassandra-server
ports:
- "8080:8080"
networks:
- app-tier
networks:
app-tier:
external: true
I am trying to use this image https://hub.docker.com/r/ibmcom/cloudant-developer/ with docker compose, when I use the original instructions it works, however when I translate it to docker compose format it doesn't work properly, I see the dashboard page but it is empty and seems broken.
The original run command:
docker run \
--privileged \
--detach \
--volume cloudant:/srv \
--name cloudant-developer \
--publish 8080:80 \
--hostname cloudant.dev \
ibmcom/cloudant-developer
The compose file I created:
version: '3'
services:
cloudant:
image: ibmcom/cloudant-developer:latest
container_name: cloudant-developer
hostname: cloudant.dev
ports:
- "8080:80"
expose:
- "80"
volumes:
- cloudant:/srv
privileged: true
volumes:
cloudant:
Thanks for helping.
P.S - I do executed the commands for license agreement manually
Took me a while to figure this out. Turns out the cloudant docker container is tied to the default docker network subnet. Specifically, I found that haproxy was mapped to redirect to 172.17.0.2:5984 and was failing because by default docker compose creates a new network in a different ip range. There may be other issues related to this. Ultimately I found that you could run docker compose on the default docker network with the following config:
network_mode: bridge
So, your docker-compose.yml would look like this:
version: '3'
services:
cloudant:
image: ibmcom/cloudant-developer:latest
container_name: cloudant-developer
hostname: cloudant.dev
ports:
- "8080:80"
expose:
- "80"
volumes:
- cloudant:/srv
privileged: true
network_mode: bridge
volumes:
cloudant: