# udocker Usage Example

## Install by your own:

See **[IBERGRID 2019 Tuturial](https://indico.lip.pt/event/575/contributions/2001/attachments/1759/2397/udocker-26-set-2019.pdf)**, check also **[the general udocker tuturials page](https://wiki.incd.pt/books/containers-tutorials/page/udocker)**

## Use the already available installation:


```
	[user@pauli02 ~]$ module avail
    
	------- /cvmfs/sw.el7/modules/soft ----------
	gcc-5.5           matlab/R2018a    trimmomatic-0.33
	gcc63/mpich-3.2   matlab/R2018b    udocker/1.1.3

	[user@pauli02 ~]$ module load udocker
    
	[user@pauli02 ~]$ module list
	Currently Loaded Modulefiles:
	  1) udocker/1.1.3
	
```

The ***udocker*** works the same way as the command ***docker***, the big difference is that it runs on *user space* and doesn't require special privileges to run, ***works everywhere***!. The docker hub repository is available and the user is able pull images from the docker hub repository and also his own images.

For example, search for a **Centos** image:

```

	[martinsj@pauli02 ~]$ udocker search centos
	NAME                                     OFFICIAL DESCRIPTION
	centos                                       [OK] The official build of CentOS.
	pivotaldata/centos-gpdb-dev                  ---- CentOS image for GPDB development. Tag...
	pivotaldata/centos-mingw                     ---- Using the mingw toolchain to cross...

```

Pull an image and list it:

```
	[martinsj@pauli02 ~]$ udocker pull centos
	Downloading layer: sha256:729ec3a6ada3a6d26faca9b4779a037231f1762f759ef34c08bdd61bf52cd704
	Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4
	Downloading layer: sha256:a3ed95caeb02ffe68cdd9fd84406680ae93d633cb16422d00e8a7c22955b46d4

	[martinsj@pauli02 ~]$ udocker images
	REPOSITORY
	centos:latest

```

Create and start a container:

```

	[martinsj@pauli02 ~]$ udocker create --name=MY_CENTOS  centos
	abfe7e30-d25d-3d47-bfc3-ff11401bb430

	[martinsj@pauli02 ~]$ udocker run --volume=$HOME --workdir=$HOME --user=$USER MY_CENTOS bash -li
	 
	 ****************************************************************************** 
	 *                                                                            * 
	 *               STARTING abfe7e30-d25d-3d47-bfc3-ff11401bb430                * 
	 *                                                                            * 
	 ****************************************************************************** 
	 executing: bash

	abfe7e30$ ls -l
	total 183852
	drwxr-xr-x  2 martinsj csys         6 Mar 21  2018 Desktop
	drwxr-xr-x  8 martinsj csys        88 Apr 17  2018 Template
	-rwxr--r--  1 martinsj csys         6 Nov  1  2018 VERSION
	...


```

Inline general help is available

```
	[martinsj@pauli02 ~]$ udocker help
	        Syntax:
	          udocker  <command>  [command_options]  <command_args>
	
	        Commands:
	          search <repo/image:tag>       :Search dockerhub for container images
	          pull <repo/image:tag>         :Pull container image from dockerhub
	          images                        :List container images
	          create <repo/image:tag>       :Create container from a pulled image
	          ps                            :List created containers
	          ...
    
```
as long as a subcommand specialized help

```
	[martinsj@pauli02 ~]$ udocker run --help
	
 	       run: execute a container
	        run [options] <container-id-or-name>
	        run [options] <repo/image:tag>
	        --rm                       :delete container upon exit
	        --workdir=/home/userXX     :working directory set to /home/userXX
	        --user=userXX              :run as userXX
	        --user=root                :run as root
	        --volume=/data:/mnt        :mount host directory /data in /mnt
	        ...

```