-
Notifications
You must be signed in to change notification settings - Fork 349
Description
Inconsistent use of SHELL instruction in Dockerfiles
We recently reviewed the use of the SHELL instruction in the Dockerfiles we use to build .NET Framework images. We found there is inconsistent use of the SHELL instruction. This inconsistency can lead to usability issues when authoring Dockerfiles that are based on these images.
We are proposing to resolve these inconsistencies by not setting the shell -- by not using the SHELL instruction -- in any of the Dockerfiles in this repo. This change is breaking. We will make this change in the next version of Windows to reduce the impact. We will not make this change for existing images that are based on existing Windows base images.
Details
What does shell mean?
Dockerfiles allow for a shell to be defined using the SHELL instruction that defines which shell executable is used to execute subsequent RUN instructions. The SHELL instruction only affects how instructions will be executed in the Dockerfile and any other Dockerfiles that are based on the image with that SHELL instruction. In other words, it is only relevant when building a Dockerfile. It has no impact on what shell is run by default when you run a container interactively (docker run -i) or execute commands on a container (docker exec). Learn more about the SHELL instruction.
Current state of shells
Here is what the landscape looks like for the shell usage across .NET Framework images:
- runtime:
cmd - aspnet:
- 3.5:
cmd - All other versions:
powershell
- 3.5:
- wcf:
powershell - sdk:
powershell
Resolving shell differences
Changing the shell is a breaking change for a given Docker image. We believe it is important for the shell to be consistent across the images that we provide. To reduce the impact of this change, we will remove the SHELL instruction for images we produce for the next Windows Server version. You will only experience this change when you start using images for this new Windows Server version, or later. We expect that we will make this change starting with Windows Server, version 2009. The change will only be observable in images that have set the shell to powershell, as described earlier.
Choosing the default shell
As a publisher of platform images, we do not believe we should be making a choice on which shell you use. The Windows base image sets a default shell -- cmd -- and we believe we should leave it unchanged. This approach is also consistent with the .NET Core images which make no use of the SHELL instruction.
Dockerfile authors are free to set their own SHELL if they desire something other than cmd. If you would like to use PowerShell, we recommend the following instruction:
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]