Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,551,681
Community Members
 
Community Events
184
Community Groups

Pipelines access docker host

Hello,

I have set the runners, self hosted to my server. Everything works fine, runner is working and spins a new container which can also have docker using docker service.

 

pipelines:
branches:
master:
- step:
services:
- docker
runs-on:
- self.hosted
- linux
script:
- docker ps -a
- docker images
- echo "OK"

 Now my problem is that docker ps -a and docker images are empty.

I think docker in docker works but is completely isolated from the host docker. However, this does not fulfill my need.

In the host (the same host the runner is running), I have the container that needs to be updated from the pipeline. I want to build a new image and run then: docker compose -f xxx.yml up -d

How can I do this using docker runner? Is the only solution using Linux shell instead which i will install directly on the host?

1 answer

1 accepted

0 votes
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
Nov 09, 2022

Hi @crash21,

This is not possible with Linux Docker Runners, as they limit access to the host.

One thing you could do is commit the Dockerfile and any other files you need to build the Docker image in your repo. These files will then be available during the build in the clone directory, so you can build the Docker image, start a container, push the image to a registry etc.

Otherwise, you can use a Linux Shell Runner, which provides access to the host. Please keep in mind that if you do things such as installing any applications, starting a database service, or editing a file outside of the build directory, during a build, these would potentially affect the next step to be run. So, you'll need to make sure that the scripts you run in each step won’t have a major impact on other steps or builds.

If you use a Linux Shell Runner, you will need to add the following command at the beginning of your script or before you run any Docker commands, in order to be able to use Docker:

- export DOCKER_HOST=""

This is because we are setting the variable DOCKER_HOST to tcp://localhost:2375, which can lead to issues.

If you have any questions, please feel free to let me know.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events