Page tree

You can use dockerrun script to run Docker container in batch script, interactive jobs or on workgroups servers.


  1. This will download a new image (if it is missed), create user and $HOME directory inside a container, mount current directory to /docker_pwd and set is as working directory

    $ whoami && ls # to test 
    $ dockerrun centos:7 whoami 
    $ dockerrun centos:7 ls # should produce same output
  2. Some images are stripped so much that they do not have some standard directories and adding user is impossible there. In this case you can use -no-add-user option. This may also be used if you do not want to overwrite /passwd and /group file in your container or you have an entrypoint specified in the image which cannot be overwritten.

    $ dockerrun -no-add-user hello-world
    $ dockerrun -no-add-user centos:7 whoami
    whoami: cannot find name for user ID ...
    $ dockerrun -no-add-user centos:7 id # you have no real user there, but all ids and gids are there.

  •  If you do not need to disable user namespace you can use original Docker commands. But remember that data access will be limited.

    $ docker run -it centos:7 whoami
    $ docker run -it -v $HOME:/test centos:7 ls /test
    ls: cannot open directory /test: Permission denied




  • No labels