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
3
votes
1 answer

How do I execute dynamic code in a container?

I'm working on a personal project involving a browser-based code editor (think https://repl.it). My plan: 1) Constantly stream the code being written to a remote docker volume on kubernetes. 2) Execute this code when the user presses "run". I've…
Jay K.
  • 546
  • 2
  • 10
  • 17
2
votes
2 answers

How do I exec into a docker container using its image name (as opposed to container ID)?

I'm using the following version of Docker $ docker -v Docker version 20.10.7, build f0df350 When I start my containers using "docker-compose up", I can see them all come up with CONTAINER ID IMAGE COMMAND CREATED …
Dave
  • 15,639
  • 133
  • 442
  • 830
2
votes
2 answers

How to use export command to set environment variable with docker exec?

I have a running docker container using an ancestor my_base_image. Now when the container is running, can I set an environment variable using export command with docker exec? if yes, how? I tried using the following, but doesn't work docker exec -i…
Kingz
  • 1,657
  • 3
  • 18
  • 29
2
votes
0 answers

Docker exec not working: input/output error

I use Docker Toolbox on Windows Server 2012. I have one container: C:\Users\Administrator\services\ndvi-service>docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS …
gustav
  • 119
  • 13
1
vote
0 answers

Capture the output of Docker EXEC through API

I'm writing a C function to take arguments "container name" and "command" to run the command inside the appointed container and return the output. I'm using libdocker to call the Restful API with curl. Currently the command can be executed…
Seraph
  • 177
  • 12
1
vote
1 answer

What does the docker exec --privileged flag do?

I've come across the --privileged flag for docker exec, but the manual does not provide much of an explanation: --privileged Give extended privileges to the command That's all. No more explanation or example. Searching the web for more info,…
not2savvy
  • 2,902
  • 3
  • 22
  • 37
1
vote
0 answers

GitLab CI failing after call php in a docker composer exec command

My CI script is failing without any error message, do you guys have any idea why? docker compose exec -T my-app-name bash -c 'php -d xdebug.mode=off ./vendor/maglnet/composer-require-checker/bin/composer-require-checker check --output=json >…
FabianoLothor
  • 2,752
  • 4
  • 25
  • 39
1
vote
3 answers

Bash scripting with docker exec when using variables

I'm trying to create a Bash script based on variables. It works well when I'm using bash command line via docker image: #docker exec app_mysql mysqldump --login-path=localroot masterdb | gzip > 1111111.sql.gz While I'm trying to reproduce the same…
user3417586
  • 53
  • 1
  • 5
1
vote
2 answers

Docker exec command is failing with EXIT CODE 137

I am running a CICD pipeline that runs a test script inside a docker container with docker exec and its failing with a return code of 137 every 3rd or 4th time. Here is the code that's running: docker-compose -p 1234 -f docker-compose.yml exec -T…
user3571643
  • 11
  • 1
  • 2
1
vote
1 answer

Triggering react tests inside docker containers

I have container with React application which is running from docker-compose. When I print logs for this container using docker-compose logs -f There is a message: PASS src/App.test.js ✓ renders learn react link (28 ms) tests_1 | Test Suites: 1…
Krzysztof
  • 33
  • 3
1
vote
0 answers

app-psql not working properly? (Using Postgres Alpine container in docker)

I want to make a command to grant a user in a Postgresql running container certain privileges from command line, without having to access psql manually inside the container. To do this you can use the app commands, here is the documentation:…
1
vote
1 answer

docker exec -t container_name takes very long time in Jenkins pipeline

I'm making a new Jenkins pipeline for my dockerized Vue application. This is my jenkinsfile content #!groovy pipeline { agent any stages { stage('Checkout') { steps { echo 'Checking out the PR' …
Mona101ma
  • 675
  • 2
  • 7
  • 25
1
vote
1 answer

Python subprocess with apostrophes, removes them

I'm running a command to my containerized Hbase DB from the subprocess.run function: subprocess.run(('docker exec hbase bash -c "echo -e create "myTable", "R" | hbase shell"'), shell=True) It seems that the command runs as I expected, it opens the…
Oded
  • 336
  • 1
  • 3
  • 17
1
vote
2 answers

Can I Run Docker Exec from an external VM?

I have a group of docker containers running on a host (172.16.0.1). Because of restrictions of the size of the host running the docker containers, I'm trying to set up an auto-test framework on a different host (172.16.0.2). I need my auto-test…
jencoston
  • 1,262
  • 7
  • 19
  • 35
1
vote
1 answer

Setting environment variable derived in container at runtime within a shell

I have custom entrypoint where a environment variable is exported. The value of the environment variable is constructed using two other variables provided at runtime. Snippet from Dockerfile CMD ["bash",…
nashter
  • 1,181
  • 1
  • 15
  • 33