Linux Reader
Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows

Pew Pew madafakas!

Access files and folders on Ext, UFS, HFS, ReiserFS, or APFS file systems from Windows
Last updated: Jul 29, 2021

How to run a shell script in Dockerfile

Here you will find out:

  • what to do to run a shell script in Dockerfile
  • what CMD, RUN, and ENTRYPOINT are
  • how to use them
  • when DiskInternals can help you

Are you ready? Let's read!

If you need to run a shell script in Dockerfile

If you’re going to run bash scripts in a Docker container, ensure that you add the necessary arguments in the scripts. New Linux users find it a bit challenging to understand the instructions of Dockerfile. This article, then, is going to explain a lot about Dockerfile.

What are CMD, RUN, and ENTRYPOINT?

CMD

This acts as an argument for ENTRYPOINT. CMD is used to set commands and/or parameters for ENTRYPOINT. Nevertheless, a bash programmer can tweak these commands and parameters.

RUN

RUN is used to execute command(s) in new layers and create new images. It is mainly used when installing a new package.

ENTRYPOINT

This is the actual program expected to run your commands in a Docker container. The default command is “/bin/sh –c”.

Using the RUN command

Remember, RUN is used when trying to install new packages to the main distribution. RUN creates a new layer after running a set of instructions. It can be used in two different ways:

Shell form:

Using the RUN command (shell form)

OR

Exec form:

Using the RUN command (exec form)

How to use CMD

CMD is used to set editable commands and parameters to be executed in a Docker container. The commands and parameters can be overwritten when a user passes the values through the command line.

There are three ways to use CMD:

Exec form:

Using CMD (exec form)

Set additional default parameters in exec form for ENTRYPOINT:

Set additional default parameters

Shell form:

Using CMD (shell form)

The first and third forms may appear familiar to you. In fact, the second form goes together with ENTRYPOINT instructions in exec form; it defines the default parameters to be suffixed after the ENTRYPOINT parameters if there are no command-line arguments running in the Docker container.

Using ENTRYPOINT

ENTRYPOINT instructions are introduced if you want the container to run as an executable. It is very much similar to CMD, but they're not the same. Unlike CMD, ENTRYPOINT commands and parameters cannot be overwritten through the command line when you run the Docker container.

There are two forms of writing ENTRYPOINT instructions:

Executable form:

Using ENTRYPOINT (executable form)

Shell form:

Using ENTRYPOINT (shell form)

The executable form allows a user to define commands and parameters for ENTRYPOINT, and also allows the user to add more parameters using any of the three CMD forms.

If you need to open Linux files

So you've got some Linux files you wish to open, but you're operating in Windows; how do you intend to open to files? It is not possible to open Linux partitions while you're in Windows; however, with the use of DiskInternals Linux Reader, you can access and view all your Linux files easily. DiskInternals Linux Reader is a software utility designed for dual-boot PC operators and virtual machines. It is a handy software tool with a user-friendly interface.

Related articles

FREE DOWNLOADVer 4.21, WinUpgrade to PROFrom $29.95

Please rate this article.
4.85 reviews