Executing Commands in Docker Containers
Executing Commands in Docker Containers
Executing a command in a Docker Container can be beneficial in many ways to DevOps teams. Docker can dynamically provide very specific environments which allow for controlled testing and execution of commands. In this solution example we will run a simple command in a Docker Image.
Pre-requisites & Environment Setup
- For ease of testing, have an Enterprise Runner running on the same host that is running Docker and use the Automatic Runner Dispatch setup.
- Must setup Docker Node Source before running this job.
- The example job assumes the base OS of Docker image is Linux based.
Setting up Docker Node Source
- Open the
Example Contentproject. - Navigate to Project Settings > Edit Nodes
- Click Add A Node Source
- Choose the
docker / container / modelentry. - Specify your Runner and Save.
More specifics about setting up this Node Source can be found on it's documentation page here.
Running the Job
Tips
To find the Docker jobs quickly in the job listing click on the docker tag at the top of the list.

The default node filter for this job is tags: "docker". Nodes discovered by the Docker node source above will automatically get this tag assigned to them. If you'd like to run the job on a particular container select it from the list.
The default command will run ls -last on any container in the target list along with the other steps in the job definition.

Here is some example output
