Installing packages on bamboo docker image
Asked by Akshithp_Reddy:

Hi, I am trying to modify the existing docker bamboo server image to suit my requirements like installing old maven version and other software's for capabilities through building docker file from Atlassian/bamboo-server image. But i am getting few issue as below while running the docker file.

E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)  
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

also if i use sudo in docker file i get the below error.

/bin/sh: 1: sudo: not found

can someone please suggest a solution or the correct way to customise the bamboo server image to suit my requirements by downloading different capabilities.

Thank you in advance.


Answers:
author: Dave Chevell
body: Hey [@Akshithp_Reddy](/t5/user/viewprofilepage/user-id/3852541) ! I'll show you how you can achieve this.

Firstly: Docker containers are meant to be "disposable" - if you destroy it and recreate it with the same configuration, you shouldn't lose anything. That being the case, I don't recommend installing packages in a running container - aside from the issues you ran into, it means that if you need to change some part of the container config, when you destroy and recreate it you'll need to install those packages all over again.

Instead, what you should do is build a *new* Docker image using our image as the base. For example, you might want to install NodeJS. You would create a new Dockerfile that looked like this:

```
FROM atlassian/bamboo-server:7.0.2

RUN apt-get update && apt-get install -y nodejs
```

Then you could build this image from your terminal by entering the directory containing your **Dockerfile** and running the following command:

```
docker build -t "atlassian/bamboo-server:7.0.2-custom" .
```

(You could tag it with whatever name you want; the above is just an example)

Then, simply run Bamboo using the custom image you created. This is, in essence, how Docker is intended to work - you can use the stock images out there directly, or you can use them as a base image to build upon and customise according to your needs.

I hope that helps!

Cheers,

Dave

comments: author: Akshithp_Reddy
body: Hi [@Dave Chevell](/t5/user/viewprofilepage/user-id/792201) Thank you very much for the explaining the procedure, i did the same in the Dockerfile and tried creating the custom image using the docker build tool but i see the following error when running the build, not only nodejs i tried installing other packages on the base image but the issue is same.

Sending build context to Docker daemon 4.096kB  
Step 1/2 : FROM atlassian/bamboo-server:7.0.2  
---\> e60f96f6a2a9  
Step 2/2 : RUN apt-get update \&\& apt-get install -y nodejs  
---\> Running in cad6cc8e743f  
Reading package lists...  
**E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)**   
**The command '/bin/sh -c apt-get update \&\& apt-get install -y nodejs' returned a non-zero code: 100**

I also tried modifying the permissions for the directories showed in the above error, but its still the same, can you please suggest any workaround for this error.

Also i am trying to run the customized bamboo-server image in docker container and triggering the build/plans using commands on command line interface as in linux/unix commmads, instead of using the GUI to start the build . are there any options in that way to trigger the build from the CLI. If yes can you please share the info that would be a great help. Thank you.


author: gmadar
body: the above did not worked for me but the next Dockerfile did:  

```
FROM atlassian/bamboo-server:7.0.2
USER root
RUN apt-get update && curl -sL https://deb.nodesource.com/setup_10.x -o nodesource_setup.sh && bash nodesource_setup.sh && apt-get install -y nodejs
USER bamboo
```