github.com/quickfeed/quickfeed@v0.0.0-20240507093252-ed8ca812a09c/doc/docker.md (about)

     1  # Notes on Using Docker
     2  
     3  Code submitted by students is being built and run inside Docker containers.
     4  After a container exits, the output is parsed and saved as a new submission entry in the database.
     5  
     6  If suddenly out of space on the production server, there are few Docker-related steps that can be taken:
     7  
     8  - Check if there are containers running for too long with `docker ps`; if necessary, kill them with `docker rm <name/id>`
     9  - Check if there are too many stopped containers waiting to be removed
    10  - Show all running and stopped containers with `docker ps -a`
    11  - To remove all stopped containers, use `docker container prune`
    12  - Restart Docker daemon with `sudo service docker restart`
    13  - Clean up all unused Docker objects with `docker system prune` (warning: can take a few minutes)
    14  
    15  To be able to run docker, the user that is running docker either has to be running as sudo user, or must be a part of the docker group.
    16  
    17  ## Linux
    18  
    19  First check that the `docker` group exists:
    20  
    21  ```console
    22  % cat /etc/group | grep docker
    23  ```
    24  
    25  This command can also be used to check which users are in the docker group, and thus can run docker containers.
    26  
    27  To stop (or delete) **all containers**, use one of these commands:
    28  
    29  ```console
    30  % docker stop $(docker ps -a -q)
    31  % docker rm $(docker ps -a -q)
    32  ```
    33  
    34  ### Useful Docker Commands
    35  
    36  ```console
    37  % docker images
    38  ```
    39  
    40  ### Helpful Tools for dealing with docker containers and too many open file descriptors
    41  
    42  ```console
    43  % pgrep quickfeed | ls /proc/$(xargs)/fd | wc -l
    44  % docker ps -a
    45  % docker stats
    46  % docker rm $(docker ps -q -f status=exited)
    47  ```
    48  
    49  ### Missing docker group
    50  
    51  If there is no docker group, add it manually with the command:
    52  
    53  ```console
    54  % sudo groupadd docker
    55  ```
    56  
    57  After this command is executed please restart your machine or restart the docker daemon with the commands:
    58  
    59  ```console
    60  % sudo systemctl restart docker.service
    61  ```
    62  
    63  or
    64  
    65  ```console
    66  % sudo service docker restart
    67  ```
    68  
    69  ### Docker group exists
    70  
    71  If it does add the user that should be running docker to this group with the given command
    72  
    73  ```console
    74  % sudo usermod -aG docker [username]
    75  ```
    76  
    77  Also make sure that the docker daemon is running,
    78  
    79  ```console
    80  % systemctl status docker.service
    81  ```
    82  
    83  or with the command
    84  
    85  ```console
    86  % service docker status
    87  ```