loading...

Docker – The SHELL instruction

Initial Server Setup with CentOS 8

As you have read in many sections throughout this chapter, there are several instructions that take two forms, the exec form or the shell form. As mentioned, the default used by all of the shell forms is ["/bin/sh", "-c"] for Linux containers, and ["cmd", "/S", "/C"] for Windows containers. The SHELL instruction allows you to change that default. Here is the syntax for the SHELL instruction:

# SHELL instruction syntax
SHELL ["executable", "parameters"]

The SHELL instruction can be used more than once in a Dockerfile. All instructions that use a shell, and that come after a SHELL instruction, will use the new shell. Thus, you can change the shell multiple times in a single Dockerfile as needed. This can be especially powerful when creating Windows containers since it allows you to switch back and forth between using cmd.exe and powershell.exe.

Comments are closed.

loading...