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
108
votes
4 answers

difference between docker attach and docker exec

Both will be able to execute commands in container. Both could detach the container. So what is the real difference between docker exec and docker attach?
MJL
  • 1,235
  • 2
  • 10
  • 6
61
votes
5 answers

How do I run a sql file of inserts through docker run?

Given a file with a SQL insert: INSERT INTO countries (id, country_code, name) VALUES (1, 'AF', 'Afghanistan'), (2, 'AL', 'Albania'); I would like to run the file by using the docker run command on a container that is running postgres. I've…
JZ.
  • 21,147
  • 32
  • 115
  • 192
28
votes
3 answers

What's the default user for docker exec?

Is root the default user when calling docker exec (without --user)? Does a USER line in the Dockerfile affect the default user for docker exec?
bcb
  • 1,977
  • 2
  • 22
  • 21
16
votes
2 answers

Enter a docker container running with Google Cloud Run

Is it possible to enter a container powered by Google Cloud Run? Something in the manner of docker exec -it CONTAINER /bin/bash? I'm facing a bug i can't reproduce running a container based on the very same image neither locally nor using Google…
nichoio
  • 6,289
  • 4
  • 26
  • 33
12
votes
2 answers

Docker exec Requires minimum of 2 arguments

I am using a shell script on Linux in order to execute some Docker commands : docker exec -t -i test1 passwd ... docker exec -t -i test2 passwd And on the second exec command I receive the following error : docker: "exec" requires a minimum of 2…
user3520669
11
votes
1 answer

Executing 'bash -c' in 'docker exec' command

Context: I'm trying to write a shortcut for my daily use of the docker exec command. For some reasons, I'm experimenting the problem that my output is sometimes broken when I'm using a bash console inside a container (history messed up, lines…
AdrienW
  • 3,092
  • 6
  • 29
  • 59
10
votes
4 answers

Execute docker commands through a node js script

Is there any better way to execute docker commands from a node js apart from using shelljs(similar packages) to execute those commands? I have seen the package dockerode. Though it is great for some commands, it doesn't give much view on 'docker…
Nithin D J
  • 299
  • 1
  • 2
  • 12
9
votes
2 answers

Write to stdin of running docker container

Say I run a docker container as a daemon: docker run -d foo is there a way to write to the stdin of that container? Something like: docker exec -i foo echo 'hi' last time I checked the -i and -d flags were mutually exclusive when used with the…
user12374570
5
votes
3 answers

Permission denied when accessing ttyUSB in a privileged docker container using "docker exec"

I'm trying to access the serial port (as a user) in my privileged docker container which is already running, but I'm getting "permission denied" errors, while the permissions should be correctly set. As a minimal reproducible example (assuming…
wilson1994
  • 93
  • 1
  • 7
5
votes
2 answers

Running powershell or cmd on docker container

I want to check the content of my docker container. I want to run a powershell or command prompt inside container so I can list directories. This container image is hosting ASP.NET Web API application using ASP.net 4.6.1 framework. I ran following…
5
votes
3 answers

How to use Deployer with Docker (Laradock)

I created a fresh Digital Ocean server with Docker on it (using Laradock) and got my Laravel website working well. Now I want to automate my deployments using Deployer. I think my only problem is that I can't get Deployer to run docker exec -it…
Ryan
  • 22,332
  • 31
  • 176
  • 357
5
votes
3 answers

docker exec is missing

I have ubuntu 14.04 and it is missing docker exec sudo docker exec -it ubuntu_bash bash I wish to run interactive bash shell in existing running docker container. sudo docker version Client version: 1.0.1 Client API version: 1.12 Go version…
Max
  • 6,286
  • 5
  • 44
  • 86
4
votes
2 answers

Docker exec command is very slow

I have built docker container system where container contains a command line application. I pass arguments and run the application using docker exec command from another application. When I run the command line application from inside docker, it…
user1235483
  • 111
  • 1
  • 1
  • 5
3
votes
1 answer

Command works inside a docker container but fails with docker exec

I'm using containerized Vespa.ai DB, and I want to execute the following commands from the host: vespa-stop-services vespa-remove-index vespa-start-services If I execute the following vespa-stop-services && vespa-remove-index &&…
Oded
  • 336
  • 1
  • 3
  • 17
3
votes
3 answers

Direct group of commands into `docker exec`

I have the following command that works fine and prints foo before returning: docker exec -i /bin/sh < echo "echo 'foo'" I want to direct multiple commands into the container with one pipe, for example echo 'foo' and ls /. I have tried the…
GammaGames
  • 1,617
  • 1
  • 17
  • 32
1
2 3 4