I have a docker composed Jenkins container running on Ubuntu 20.04. When I push my code, a job is auto started in Jenkins. And a docker build operation is executed, after that a docker compose up -d operation is also executed. My Application is up and runing but not reachable...
When I run docker ps on Ubuntu, there is no container of my Application, because the docker container of my app was built inside the Jenkins Container, and docker compose up was also executed inside my jenkins container.
I want to achieve that my app runing side by side with Jenkins and other Container on Ubuntu not inside Jenkins Container. How I can achieve that?
CodePudding user response:
Assuming you have an application that is dockerized. The Jenkins is also running on a docker container exposed at some port. Then you can open Jenkins and write a freestyle Job for deployment which would do the following:
- Have a deploy folder where the shellscript is written as per below. This build repository could be within the same repo as the source code or somewhere else as well.
ssh -i key user@server '
# The command here are run within this ssh session.
#Checkout your code from version control
git clone your_repo
#build your docker services
cd your_repo
docker-compose build service1
docker-compose build service2
...
#run your built services
docker-compose up -d service1
docker-compose up -d service2
...
'
Now, the application should be deployed and accessible for you and Jenkins should be able to notify the same.