Copy file from bamboo user/host to docker container - docker

I am using docker task in my bamboo to build the project. To build the project I need to copy some file from bamboo user to the docker container.
We can copy a file from the host to the docker container by docker cp command but how can we do this in bamboo. I am not able to find any useful post. Anyone have any idea or a link to copy a file to docker in bamboo.
I am using run a docker container from image.

In case someone else having this issue --
I have used volumes to mount host/bamboo directory in the Docker container and then I can access the file in the Docker container ("Additional arguments" or "Volumes" section).

Related

How containerd copy a file from host to a running container?

I find that I can use ctr snapshot mount to copy a file from a container to a host.
But how can I copy a file from a host to the container using containerd?
I used golang to write some code to start a container, but I can't find any documentation about copying host files to a running container.
As of now there is no provision as such with either with ctr or crictl cli to copy a host file to a running container as we have with docker cli (eg: docker cp).
Though there is a project under containerd known as nerdctl which is trying to emulate the same.
nerdctl is a Docker-compatible CLI for containerd.
Link for reference: Nerctl cp command

Run command on jenkins docker container to copy file to host

Is there a way to copy file from docker container to the host by running the command on the container itself?
I know that I can use "volume" but it will not work - I want to copy files from container to arbitrary places on the host.
Only SCP file vis SSH?
From: Copying files from Docker container to host you can run:
docker cp <containerId>:/file/path/within/container /host/path/target

how to configure Cassandra.yaml which is inside docker image of cassandra at /etc/cassandra/cassandra.yaml

I am trying to edit cassandra.yaml which is inside docker container at /etc/cassandra/cassandra.yaml, I can edit it from logging inside the container, but how can i do it from host?
Multiple ways to achieve this from host to container. You can simple use COPY or RUN in Dockerfile or with basic linux commands as sed, cat, etc. to place your configuration into the container. Another way you can pass environment variables while running your cassandra image which will pass those environment variables to the spawning container. Also, can use the docker volume mount it from host to container and you can map the configuration you want into the cassandra.yaml as shown below,
$ docker container run -v ~/home/MyWorkspace/cassandra.yaml:/etc/cassandra/cassandra.yaml your_cassandra_image_name
If you are using Docker Swarm then you can use Docker configs to externally store the configuration files(Even other external services can be used as etcd or consul). Hope this helps.
To edit cassandra.yaml :
1) Copy your file from your Docker container to your system
From command line :
docker ps
(To get your container id)
Then :
docker cp your_container_id:\etc\cassandra\cassandra.yaml C:\Users\your_destination
Once the file copied you should be able to see it in your_destination folder
2) Open it and make the changes you want
3) Copy your file back into your Docker container
docker cp C:\Users\your_destination\cassandra.yaml your_container_id:\etc\cassandra
4) Restart your container for the changes to be effective

How to mount a container's directory in a docker run command

I am trying to run a "build container" which simply builds an output file from source code and then exits. So I have to bind mount the source code directory when running this build container so that it can build the output file.
The complicated part is that the source code directory is inside a separate container.
One solution is to manually copy the source code directory from the separate container to the docker host. Then I can give the path to the source code directory on the docker host, like docker run --mount type=bind,src=/path/to/sourcecode,dst=/local build_container.
The separate container has access to the docker socket so I can issue docker commands directly from it. I would like to be able to run the "build container" from this separate container so that the docker daemon magically knows that the source directory is on this separate container.
Is there a way to do that without having to manually copy the source code directory back to the docker host?

How do access file located in host from Jenkins installed in a local docker container

How can I connect my Jenkins in docker to my hosts local filesystem. I need to build a code snippet in my local filesystem from the Jenkins shell
It's not quite clear what do you mean by 'connect' but you can copy your code from docker via:
docker cp "$(docker ps -aqf name=your_image):/opt/path/to/your/file" .
ReBuild your docker image with the following (mind meta there):
FROM jenkins_image
COPY /your_project_dir/ /your_build_dir_injenkins/

Resources