Questions tagged [docker-exec]

`docker exec` is a debugging command to run an additional command in a Docker container. Use this tag for questions about the Docker exec subsystem, especially invoking it through a Docker SDK.

docker exec is a debugging command to run an additional command in a container. A typical use could be to inspect the container filesystem after a container has already started up:

# Start the container
docker run -d --name container-name ...

# See what is in the container's `/data` directory
docker exec container-name ls /data

The command can also be invoked using the longer alias docker container exec. For based setups, docker-compose exec name command will use the container's Compose service name, without needing to know the generated container name.

Programming-related questions about docker exec will generally focus on invoking it through a Docker SDK. Some debugging tasks may be on-topic as well.

60 questions
1
vote
1 answer

How do i run a single docker exec command against multiple containers

I am currently running a mac mini hosting at anytime 2 to 6 docker containers built off the same agent. The container function as build agents but every now and then builds fail and do not clean up correctly. This leads to files being left over that…
Riaz Abed
  • 27
  • 1
  • 5
1
vote
1 answer

Why is executing "docker exec" killing my SSH session?

Let's say I have two servers, A and B. I also have a bash script that is executed on server A that looks like this: build_test.sh #!/bin/bash ssh user@B <<'ENDSSH' echo "doing test" bash -ex test.sh echo "completed…
Nathan Jones
  • 4,904
  • 9
  • 44
  • 70
1
vote
1 answer

Docker container - what's the best practice to inject to it a sensitive data

I have a service that sends emails. I'd rather not to keep my Gmail password in any file. After googling I found that I can provide environment variables to the containers with --build-arg param while building them. The Dockerfile file FROM…
1
vote
1 answer

How to use ">>" operator in Docker?

I'm trying to append a string to a file in a docker container using docker exec. However, it doesn't seem to interpret properly the ">>" operator sudo docker exec --interactive mycontainer cat /etc/postfix/main.cf returns smtpd_banner =…
Arthur Attout
  • 2,701
  • 2
  • 26
  • 49
0
votes
1 answer

Even without docker exec -t, the output is there

I understood docker's -t as a kind of virtual terminal that seems to access the terminal through /dev/pts. So, if I do echo "hello, tty" > /dev/pts/1 , I see that it is output to the connected terminal. Since the -i option is STDIN, the container…
Hwan E
  • 566
  • 2
  • 13
0
votes
0 answers

How to access secret variable using exec form in Dockerfile?

I am injecting a secret from the Github build pipeline. I can see the secret (a dummy value for now) being echoed in the run of the Dockerfile. I want to use the exec form for accessing the secret. Currently I have the following so far but it…
Katlock
  • 1,200
  • 1
  • 17
  • 41
0
votes
0 answers

Trouble making a drupal drush site-install through docker exec

I am trying to develop an automatic Drupal installer which creates an already configured Drupal docker container ready to be used with one single command execution. In order to achieve this, I have this docker-compose.yml: version: "3" services: …
pabpazjim
  • 13
  • 2
0
votes
0 answers

python docker-sdk, attach to exec command

I'm writing something like a website to run code in various languages. I chose docker as a way to isolate the process from the internet and the file system. Typical docker usage example: Create a container with all the necessary environment…
semwai
  • 1
  • 1
0
votes
1 answer

Cannot backup mariadb docker from crontab

So I have a mariadb in a container in /home/admin/containers/mariadb. This directory also contains an .env-file with MARIADB_ROOT_PASSWORD specified. I want to backup the database using the following command: * * * * * root docker exec --env-file…
Felix D.
  • 4,811
  • 8
  • 38
  • 72
0
votes
0 answers

docker exec and running state

I built an image, say my_dbt_image, with a custom install of a program, say dbt. I also wrote a little binary my_dbt like: #!/usr/bin/env bash # define flags, e.g. '--workdir=/vol' '--volume $PWD:/vol' docker run --rm $flags my_dbt_image dbt $@ so…
Brice
  • 13
  • 4
0
votes
0 answers

how to use paramiko to access a docker container running on ec2

I am new to python, and programming in general, so this question may be due to my simple lack of knowledge I am running a container on an Ec2 Instance (through ECS). I would like to write a python script which will 'exec' into the containers and…
yaniv
  • 1
  • 1
0
votes
1 answer

docker exec error "/data # ^[[2;9R" when try get shell or ash

when I'm executing a command in docker to get container bash, I'm faced with such a message and I can not enter any commands docker exec -u 0 -t my_local_redis ash and error is: /data # ^[[2;9R but when I run the below command it seems…
0
votes
1 answer

Access container from service on other node in Docker Swarm

I have Docker running in swarm mode, and created a service that runs one container. The service my-service runs on node1 (Manager node), and the container my-container is spawned on node2 From node1, how can I make a docker exec on the my-container…
neophat
  • 187
  • 1
  • 10
0
votes
1 answer

Assign and return bash variable from a running Docker container using exec

I'm just trying to get the hang of how to work with an active Docker container I/O using the exec function. I created a simple container with a bash session: docker run -it -d --name my_container ubuntu bash I gave the container a variable docker…
jjschuh
  • 187
  • 1
  • 2
  • 8
0
votes
1 answer

Docker Error: OCI runtime exec failed: exec failed: container_linux.go

I have created a docker image named ocp-install from the following dockerfile FROM registry.access.redhat.com/ubi8/ubi-minimal:latest ARG INSTALL_DIR=/root/install-dir ENV PATH $PATH:$INSTALL_DIR WORKDIR $INSTALL_DIR RUN…
AishwaryaK
  • 61
  • 2
  • 11