Step 7: Test the Docker Image

Now that the Docker image is created, you must test the Docker image using the Docker run command. The Docker run command differs slightly for a root user and a non-root user. (The Docker run command executes the startall.sh script.)

The Docker run command allows you to redirect the container ports to the ports on the Docker host.
Note: Make sure that the ports defined by the -p parameter are unique and available on the Docker host when running multiple Docker containers on the same Docker host.

Procedure

  • To test the docker image, execute the Docker run command depending on whether you are a root or a non-root user. See the sample provided in the following table.
    User RUN Command Sample
    Root User docker run -it --rm -p 46464:46464 -p 56565:56565 -p 58585:58585 -v /persiststorage:/psupersist:z library/psu8.0.1
    Non-root User docker run -it --rm docker run -it --rm -p 46464:46464 -p 56565:56565 -p 58585:58585 -u mftuser:mftuser -v /persiststorage:/psupersist:z library/psu8.0.1
    The following table describes the parameters in the run command:
    Parameter Descriptions
    -p 46464:46464 -p 56565:56565 -p 58585:58585 Maps the ports used by the container to the ports accessible by the network
    -u mftuser:mftuser Defines the user ID and group ID used by the container. This is required only when running the container as a non-root user. The user defined in this command must match the user created in the dockerfile.
    -v /psupersiststorage:/psupersist:z: Defines the persistent storage used by the container. This storage is used for saving critical files across container restarts. The persistent storage defined must match the persistent storage directory defined in the startall.sh script.
    -library/psu8.0.1 Defines the name of the docker image.
    Note: If you have made any changes to the Docker image that you want to make permanent, you can use the Docker commit command to commit the changes to an image. However, make sure to do this before the Docker image is removed.