I am newbie to Docker. I have created Jenkins instance with Docker with jdk1.8 latest image but the URL get down after sometime while the containers are still running. It works after I restart docker service but it also get down eventually after sometime .
Dockerfile
Using official docker image jenkins/jenkins:latest-jdk8 , the only customized item is addition of plugins through Jenkins plugin cli in the image.
To run the instance, docker compose is used with minimal configuration mentioned in image document.
docker-compose.yaml
version: "3.3"
services:
mylocaljenkins:
image: jenkins/jenkins:latest-jdk8
container_name: jc
privileged: true
restart: unless stopped
user: root
port:
- "8080:8080"
- "50000:500000"
volumes:
-/root/mount:/var/jenkins
Related
I use docker-compose to run containers to build different components as part of my CI/CD pipeline. Recently I have started noticing that the build pipeline fails sometimes while trying to download build dependencies from the internet in run time, as sometimes these links are down.
To fix this I want to test running the docker container which builds these applications without any internet connection, I want to include all the required dependencies which are downloaded at runtime as part of the docker image.
Can someone let me what change should I make in my docker-compose so that the container starts without any network access?
Here is a sample of my docker-compose file:
version: "3.7"
services:
build-component-1:
image: base-image:1
network_mode: host
volumes:
- "$PWD:/build-dir"
command: ./build.sh build_app1
working_dir: /build-dir
privileged: true
environment:
- USER=root
- VAR1=$VAR1
env_file:
- version.txt
Found the answer here - https://docs.docker.com/compose/compose-file/compose-file-v3/
I have to replace network_mode: host with network_mode: none in the docker-compose file.
I have Docker Desktop running, and inside I got Nexus repository running. I have logged into repository.
I have pushed the image and I'm able to pull it like:
docker pull localhost:8123/node-web-app:mytag
But, how should I configure docker-compose.yml to pull the image from private nexus repo running on localhost? When I run the docker-compose up, image is not pulled but builded.
Currently I have in docker-compose.yml:
services:
frontapp1:
build:
context: .
dockerfile: Dockerfile
image: 127.0.0.1:8123/node-web-app:latest
container_name: nodejs
restart: unless-stopped
ports:
- "49160:8080"
I have also tried with:
image: localhost:8123/node-web-app:latest
Nexus UI is running behind port 8081, I guess I should not use that port?
I'm using docker-compose to mount a volume on an image. I have the container running, but not able to pull the image in the browser.
Docker-compose has these below lines -
version: '2'
services:
jenkins:
image: image_name
restart: unless-stopped
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /home/gp_oes/project/jenkins_home:/var/jenkins_home
ports:
- 8080
I think you are trying to download the official image of ubuntu (https://hub.docker.com/_/jenkins) which was deprecated since last 2 years.
Please check with the community image of jenkins (https://hub.docker.com/r/jenkins/jenkins)
if it is not the case please provide error with command and image name also to give better understanding of the question.
Scenario:
With the following docker-compose.yaml
version: 3
services:
helloworld:
image: hello-world
container_name: hello-world
whoami:
image: containous/whoami
container_name: whoami
containers are started with docker-compose up
docker-compose.yaml is then edited to expose a port
version: 3
services:
helloworld:
image: hello-world
container_name: hello-world
whoami:
image: containous/whoami
container_name: whoami
ports:
- 10000:80
whoami is restarted via docker-compose restart whoami
Problem: the port is not exposed.
My question: what is the correct command to restart a container (previouly started as part of a docker-compose up) so that its (modified) definition in docker-compose.yaml is taken into account?
Note: restarting everything with docker-compose down && docker-compose up correctly exposes the port. What I want to avoid is to interfere with other running containers when modifying a single one.
Only another docker-compose up seems to work.
According to docker-compose up documentation:
If there are existing containers for a service, and the service’s configuration or image was changed after the container’s creation, docker-compose up picks up the changes by stopping and recreating the containers (preserving mounted volumes).
I'm trying to migrate working docker config files (Dockerfile and docker-compose.yml) so they deploy working local docker configuration to docker hub.
Tried multiple config file settings.
I have the following Dockerfile and, below, the docker-compose.yml that uses it. When I run "docker-compose up", I successfully get two containers running that can either be accessed independently or will talk to each other via the "db" and the database "container_name". So far so good.
What I cannot figure out is how to take this configuration (the files below) and modify them so I get the same behavior on docker hub. Being able to have working local containers is necessary for development, but others need to use these containers on docker hub so I need to deploy there.
--
Dockerfile:
FROM tomcat:8.0.20-jre8
COPY ./services.war /usr/local/tomcat/webapps/
--
docker-compose.yml:
version: '3'
services:
app:
build:
context: .
dockerfile: Dockerfile
ports:
- "8089:8080"
volumes:
- /Users/user/Library/apache-tomcat-9.0.7/conf/tomcat-users.xml:/usr/local/tomcat/conf/tomcat-users.xml
depends_on:
- db
db:
image: mysql:5.7
container_name: test-mysql-docker
ports:
- 3307:3306
volumes:
- ./ZipCodeLookup.sql:/docker-entrypoint-initdb.d/ZipCodeLookup.sql
environment:
MYSQL_ROOT_PASSWORD: "thepass"
Expect to see running containers on docker hub, but cannot see how these files need to be modified to get that. Thanks.
Add an image attribute.
app:
build:
context: .
dockerfile: Dockerfile
ports:
image: docker-hub-username/app
Replace "docker-hub-username" with your username. Then run docker-compose push app