Real Execution
Part of the Introduction to Docker section of Coddy's Terminal journey — lesson 8 of 40.
Commands inside a container run for real, not as a fake echo. You can prove this by giving the container a shell and a small script:
docker run alpine sh -c "echo abc | tr a-z A-Z"Here sh -c runs a shell command string inside the container. The shell pipes abc into tr, which converts it to uppercase, so the output is ABC.
This means you can use pipes, variables, and the command-line tools you already know, all inside the container.
Challenge
EasyRun a container from alpine that uses sh -c to print the numbers 1 through 3, one per line, using seq 3.
Cheat sheet
Use sh -c to run a shell command string inside a container:
docker run alpine sh -c "echo abc | tr a-z A-Z"This allows pipes, variables, and CLI tools to work inside the container.
Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Introduction to Docker
3Running Containers
Running A CommandReal ExecutionDifferent DistrosAuto-Remove ContainersRecap - Container Runner