It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Can't build dockerfile in bamboo build

Wellington Silva Feb 09, 2015

I have made a script task to run during a build and it should build and start some docker containers based on dockerfiles but it gives me the following error:

Building proxy...
Couldn't connect to Docker daemon at http+unix://var/run/docker.sock - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.

I have made some tests accessing ec2 instance and trying to run simple docker commands like

docker ps

When I run as bamboo or ec2-user user

su - bamboo -c "docker ps"
# or
su - ec2-user -c "docker ps"

it shows me the error:

su - bamboo -c "docker ps"
2015/02/09 12:34:05 Get http:///var/run/docker.sock/v1.14/containers/json: dial unix /var/run/docker.sock: permission denied
su - ec2-user -c "docker ps"
2015/02/09 12:34:05 Get http:///var/run/docker.sock/v1.14/containers/json: dial unix /var/run/docker.sock: permission denied

When I run as root it runs normally:

sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

 

What should I do to run this script?

 

1 answer

1 accepted

1 vote
Answer accepted
Pawel Skierczynski Atlassian Team Feb 09, 2015

There are two parts of it.

Docker service must be started as a root, so it's best done during system startup etc.

Docker client can be accessed with user that is not root but is in docker group. It depends on docker version as it was changing.

Look here: http://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo

Or here: https://docs.docker.com/installation/ubuntulinux/#giving-non-root-access

 

Wellington Silva Feb 09, 2015

Hello Pawel.

First of all I would like to thank you.
I made a change in the script task to run with "sudo".  It worked fine. I am facing another issue now: 

"...Service 'redis' failed to build: Error pulling image (unstable) from debian, Driver devicemapper failed to create image rootfs..."

Seems to be Device Mapper vs AUFS stuff. Anyway I am still searching. 

Thanks again.

Pawel Skierczynski Atlassian Team Feb 09, 2015

sudo is usually not the best option but it's simple so if it's enough for you that's ok too it seems race condition on device mapper is neverending story. Especially when building new image. Maybe as you suggest you can try switching to different storage. If docker and kernel is kind of new you could try "-s overlay" when starting docker service. You've probably seen this already: https://docs.docker.com/reference/commandline/cli/ (section "Daemon storage-driver option")

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Next-gen

Introducing subtasks for breaking down work in next-gen projects

Teams break work down in order to help simplify complex tasks. This is often done iteratively, with tasks being broken down into smaller tasks and so on until the work is accurately captured in well-...

7,260 views 23 35
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you