Copy file to docker container via Ansible
1.2k Views Asked by Ali AtI want to copy a file to a docker container, as one of my Ansible playbook steps. I create the file with jinja2 "template". I can copy the file in /tmp/ and the run a command to copy it to the docker container, such as:
`docker cp /tmp/config.json my_image:/app/config/path/`
But I'm looking for the better way not to use "/tmp" or like that.
1
There are 1 best solutions below
Related Questions in DOCKER
- sqlplus myusername/mypassword@ORCL not working with Oracle on Docker
- Golang == Error: OCI runtime create failed: unable to start container process: exec: "./bin": stat ./bin: no such file or directory: unknown
- Only the first SQL script gets executed inside Docker Postgres container
- Retrieve the Dockerfile configuration from the Kubernetes and also change container Java parameter?
- Polars with Rust: Out of Memory Error when Processing Large Dataset in Docker Using Streaming
- Compiling eBPF program in Docker fails due to missing '__u64' type
- AttributeError: module 'numba' has no attribute 'generated_jit'
- Phoenix in a docker dev environment - generated code can't be saved from VSCode
- Docker on Multipass VMs: Connecting worker nodes to swarm results in rcp error
- Facing error in creating image of my react+vite project . Dockerfile error
- NextJS Docker build fails: fetch failed ECONNREFUSED
- Docker container unable to make HTTPS requests to external API
- Failed to connect to your instance after deploying mern app on aws ec2 instance when i try to access frontend
- Connecting to Postgres running in a Docker container using psql
- Can't connect to local postgresql server from my docker container
Related Questions in ANSIBLE
- Kubernetes cluster on GCE connection refused error
- editing pass option in /etc/fstab with ansible
- Ansible role analysis with Checkov - facts evaluation?
- read contents from a file on git using ansible
- Upgrade Gitlab-runner package in amazon Linux 2 and Ubuntu 22.04 through Ansible
- Ansible - Copy Same File to Many Different Paths
- Execute handler as idempotent approach
- How to discern, whether Ansible runs in color mode?
- ansible + packer +windows ami giving "msg": "winrm or requests is not installed: No module named 'winrm'"
- Moving Template or OVA to Datastore using vCenter API
- Ansible - Trouble with conditional
- Increment number on each node with excluding one
- How can I run a command before the playbook when using ansible ee?
- Connect ssh to cisco switch with ansible
- How to use the Ansible Shell module on Linux to start Node.js server in the background?
Related Questions in DOCKER-CP
- `docker cp` fails when executed within a script
- Docker cp command does not delete unshared files when replacing directory in container
- Is there a way to copy the contents of the directory into the Docker container?
- Copy file to docker container via Ansible
- How can I check for directory existence before docker cp in jenkins pipeline
- 'Docker cp' with parameter expansion (PowerShell)
- Docker cp containers in a swarm?
- How can I stop docker from truncating long filenames when I copy from a container?
- Can't use docker cp to copy file from /tmp
- Docker cp parameter expansion in powershell
- Copying files from docker container to the host fails
- Sending files from one docker container to another
- How to `docker cp` ssh key to docker container before its entrypoint is executed
- Copy .txt files from docker container to host
- How to push a shared volume or shared image to ECR
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular # Hahtags
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Ansible has a
dockerconnection plugin that you can use to interact with existing containers in your playbook. For example, if I have a container namedmycontainer:I can create an Ansible inventory like this that sets the
ansible_connectionvariable tocommunity.general.docker:Now I can target the container in a play like this: