github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/docs/docker_main.md (about)

     1  ---
     2  layout: post
     3  title: DOCKER MAIN
     4  permalink: /docs/docker-main
     5  redirect_from:
     6   - /docker_main.md/
     7   - /docs/docker_main.md/
     8  ---
     9  
    10  ## Introduction
    11  
    12  AIStore can be run as a cluster of Docker containers. There are two modes of operation: development and quick-start. They can be found in the [`deploy/dev/docker`](/deploy/dev/docker) directory.
    13  
    14  ### Development Mode
    15  
    16  This mode is currently used for development purposes.
    17  All docker containers mount the same host's AIStore source directory, and then execute from this single source. Upon restart (of the AIStore cluster), all changes made in the host will, therefore, take an immediate effect.
    18  
    19  > The development mode is currently being maintained and updated.
    20  
    21  ### Quick Start Mode
    22  
    23  Use this mode if you would like to set up a containerized, one-proxy, one-target deployment of AIStore within seconds. [See quick start AIS with Docker](/deploy/dev/docker/README.md#quick-start-ais-cluster). You just need Docker installed to quick-start AIS.
    24  
    25  For an introduction to Docker, please watch [Docker 101 youtube](https://www.youtube.com/watch?v=V9IJj4MzZBc)
    26  
    27  ## Install Docker and Docker Compose
    28  
    29  **Note:** Using Docker requires one of the following versions of Ubuntu:
    30  * Bionic 18.04 (LTS)
    31  * Xenial 16.04 (LTS)
    32  * Trusty 14.04 (LTS)
    33  
    34  1. Uninstall any old versions of docker:
    35  
    36  ```console
    37  $ sudo apt-get remove docker docker-engine docker.io
    38  ```
    39  
    40  It’s OK if apt-get reports that none of these packages are installed.
    41  
    42  2. Update the apt package index:
    43  
    44  ```console
    45  $ sudo apt-get update
    46  ```
    47  
    48  3. Install packages to allow apt to use a repository over HTTPS:
    49  
    50  ```console
    51  $ sudo apt-get install \
    52      apt-transport-https \
    53      ca-certificates \
    54      curl \
    55      software-properties-common
    56  ```
    57  
    58  4. Install Docker
    59  
    60  ```console
    61  $ sudo apt-get install docker-ce
    62  ```
    63  
    64  **Note:** For version `16.04` and up, `docker-ce` is not in the default Ubuntu repository. See [this guide](https://docs.docker.com/v17.09/engine/installation/linux/docker-ce/ubuntu/#install-docker-ce-1) for `docker-ce` installation.
    65  
    66  5. Verify that Docker CE is installed correctly by running the "hello-world" image.
    67  
    68  ```console
    69  $ sudo docker run hello-world
    70  ```
    71  
    72  6.  Add your current user to the Docker group (but only if you are not the root). After executing the command, restart your machine for it to take effect.
    73  
    74  ```console
    75  $ sudo usermod -aG docker $(whoami)
    76  ```
    77  
    78  7. Install Docker-Compose using python `pip`. Install `pip` if you don't have it:
    79  
    80  ```console
    81  $ sudo apt-get install -y python-pip
    82  $ sudo pip install docker-compose
    83  ```
    84  
    85  OR
    86  
    87  ```console
    88  sudo apt install docker-compose
    89  ```
    90  
    91  8. Test the installation:
    92  
    93  ```console
    94  $ docker-compose --version
    95  docker-compose version 1.23.1, build 1719ceb
    96  ```
    97  
    98  9. If you have any troubles with your installation, consider using the latest version of [Docker](https://docs.docker.com/install/) and [Docker-Compose](https://github.com/docker/compose/releases).
    99  
   100  ## Uninstall Docker and Docker Compose
   101  
   102  1. To uninstall Docker, run the following:
   103  
   104  ```console
   105  $ sudo apt-get purge docker-ce
   106  $ sudo apt-get purge docker-ce-cli
   107  ```
   108  
   109  2. Ensure docker is completely uninstalled by running the following command:
   110  
   111  ```console
   112  $ dpkg -l | grep -i docker
   113  ```
   114  
   115  There should be no docker-ce and docker-ce-cli packages listed.
   116  
   117  3. To uninstall Docker-Compose, run the following:
   118  
   119  ```console
   120  $ pip uninstall docker-compose
   121  ```
   122  
   123  4. Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:
   124  
   125  ```console
   126  $ sudo rm -rf /var/lib/docker
   127  ```
   128  
   129  ## Starting AIStore
   130  
   131  If not already done, [install Go](https://golang.org/doc/install) and [set $GOPATH](https://golang.org/doc/tutorial/getting-started) environment variable.
   132  
   133  The steps:
   134  
   135  1. Build `aisnode`.
   136  
   137  ```console
   138  $ go install github.com/NVIDIA/aistore/cmd/aisnode@latest
   139  ```
   140  
   141  2. To get all sources and use scripts, you can clone AIStore repo.
   142  
   143  ```console
   144  $ git clone https://github.com/NVIDIA/aistore.git
   145  ```
   146  
   147  3. Optionally, setup AWS configuration by running [`aws configure`](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html) command.
   148  To run AIStore Docker containers, you will need to pass your AWS config and credential directory via flag `-a=<aws directory>` CLI. By default, AWS stores config and credential files in `~/.aws/`
   149  Example:
   150  
   151  ```console
   152  $ ./deploy_docker.sh -a=~/.aws/
   153  ```
   154  
   155  Building and running "containerized" AIStore is further documented at [`deploy/dev/docker`](/deploy/dev/docker/README.md).
   156  Please note: the image building process will take some time but only for the first time; subsequent runs will use already cached images.
   157  
   158  ## Helpful docker commands
   159  
   160  ### List Running Containers
   161  
   162  List all of the running containers using `docker ps`. Many commands require the CONTAINER ID or NAME fields. Example output:
   163  
   164  ![docker ps](images/docker_ps.png)
   165  
   166  ### List All Containers
   167  
   168  Lists all containers (not only the running ones).
   169  
   170  ```console
   171  $ docker ps -a
   172  ```
   173  
   174  ### View Container Logs
   175  
   176  To view docker logs, use `docker logs <container_name>`. Example:
   177  
   178  ```console
   179  $ docker logs ais0_proxy_1
   180  I 21:23:56.400794 metasync.go:142] Starting metasyncer
   181  I 21:24:06.415473 stats.go:422] {"err.n":0,"get.n":0,"del.n":0,"get.ns":0,"kalive.ns":0,"err.get.n":0,"err.list.n":0,"pst.n":0,"ren.n":0,
   182  "lst.ns":0,"uptime.ns":0,"kalive.ns.max":0,"err.delete.n":0,"err.post.n":0,"err.range.n":0,"err.head.n":0,"put.n":0,"lst.n":0,
   183  "kalive.ns.min":0,"err.put.n":0}
   184  I 21:24:08.386182 proxy.go:2236] joined target 1463af8ddcd3 (num targets 1)
   185  I 21:24:11.759453 proxy.go:2236] joined target 3c86e5e71978 (num targets 2)
   186  I 21:24:12.411714 earlystart.go:262] Reached the expected 2/2 target registrations
   187  I 21:24:12.412098 earlystart.go:228] 0e76b56086eb: merged local Smap (2/1)
   188  I 21:24:12.412244 metasync.go:290] dosync: smaptag, action=early-start-have-registrations, version=2
   189  I 21:24:12.412772 metasync.go:290] dosync: bucketmdtag, action=early-start-have-registrations, version=1
   190  I 21:24:13.425617 earlystart.go:307] 0e76b56086eb: merging discovered Smap v2 (2, 1)
   191  ...
   192  ```
   193  
   194  Note:
   195  * You can obtain the container name by running command `docker ps`
   196  * The `deploy/dev/docker/` directory has a more comprehensive script named `logs.sh` to view logs
   197  
   198  ### SSH Into a Container
   199  
   200  ```console
   201  $ docker exec -it CONTAINER_NAME /bin/bash
   202  ```
   203  
   204  Note:
   205  * In production mode, the logs are expected to be in `/var/log/ais/`.By default (development mode) the logs are under `tmp/ais/log`
   206  * The `deploy/dev/docker/` directory has a script named `container_shell.sh` that does the same thing
   207  
   208  ### List Docker Images
   209  
   210  ```console
   211  $ docker image ls
   212  REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
   213  ais1_proxy          latest              ced2cbd2ff2f        27 minutes ago      676MB
   214  ais1_target         latest              ced2cbd2ff2f        27 minutes ago      676MB
   215  ais0_proxy          latest              4c3fbcb54e4d        27 minutes ago      676MB
   216  ais0_target         latest              4c3fbcb54e4d        27 minutes ago      676MB
   217  ```
   218  
   219  ### List Docker Networks
   220  ```console
   221  $ docker network ls
   222  NETWORK ID          NAME                    DRIVER              SCOPE
   223  cb05b22edcb3        bridge                  bridge              local
   224  86517bef938d        ais0_internal_control   bridge              local
   225  51f49b56fe57        ais0_internal_data      bridge              local
   226  2cee0651aa72        ais0_public             bridge              local
   227  e11635deb15d        ais1_internal_control   bridge              local
   228  9eefba13018f        ais1_internal_data      bridge              local
   229  674fee80acac        ais1_public             bridge              local
   230  ```
   231  
   232  ### Start a Container
   233  
   234  ```console
   235  $ docker start CONTAINER_NAME
   236  ```
   237  
   238  ### Stop a Container
   239  
   240  ```console
   241  $ docker stop CONTAINER_NAME
   242  ```
   243  
   244  ### Restart a Container
   245  
   246  ```console
   247  $ docker restart CONTAINER_NAME
   248  ```
   249  
   250  ### Kill a Container
   251  
   252  ```console
   253  $ docker kill CONTAINER_NAME
   254  ```
   255  
   256  ### View Resource Usage Statistics for all Containers
   257  
   258  ```console
   259  $ docker stats
   260  ```
   261  
   262  ### Remove Unused Images
   263  
   264  ```console
   265  $ docker image prune -f
   266  ```
   267  
   268  ### Remove all Stopped Containers
   269  
   270  ```console
   271  $ docker container prune -f
   272  ```
   273  
   274  ### Remove all Unused Networks
   275  
   276  ```console
   277  $ docker network prune -f
   278  ```
   279  
   280  ### Stop all Running Containers
   281  
   282  ```console
   283  $ docker stop $(docker ps -a -q)
   284  ```
   285  
   286  ### Delete all Existing Containers
   287  
   288  ```console
   289  $ docker rm $(docker ps -a -q)
   290  ```
   291  
   292  ### Delete all Existing Images
   293  
   294  ```console
   295  $ docker rmi $(docker images -q -a)
   296  ```
   297  
   298  ## Docker playground
   299  
   300  Following is a super-simple presentation to showcase some of the AIS capabilities.
   301  
   302  In [Docker playground](/deploy/dev/docker/playground), you can find the scripts to download different popular AI datasets (e.g., MNIST and ImageNet). The datasets are downloaded with the AIS-integrated [Downloader](/docs/downloader.md) that stores all downloaded objects directly into the AIStore.
   303  
   304  During the download, you can monitor:
   305  
   306   * number of requests made
   307   * number of requests failed
   308   * number of bytes transferred
   309  
   310  In the example below, AIS downloads a handful of ImageNet images and collects/visualizes the corresponding statistics:
   311  
   312  ```console
   313  $ cd path_to/deploy/dev/docker
   314  $ ./deploy_docker.sh -d=2 -p=2 -t=4 -c=1 -grafana -nocloud # start 2 proxies and 4 targets
   315  $ ./playground/download_imagenet.sh # download some of ImageNet images into AIS and show stats
   316  # once Downloader will save the files...
   317  $ ./playground/stress_get.sh imagenet # do gets on saved files (requires jq command)
   318  $ ./stop_docker.sh -l # stop docker
   319  ```
   320  
   321  ![Playground Grafana dashboard](images/playground-grafana.png)