# General Docker Information

====================================================================================

To preface this page; I personally recommend trying out [Portainer](https://www.portainer.io/), which is essentially a web GUI for Docker - it's great. Portainer even lives in a docker container itself.

Regarding images and container management; the contents of this page are great if you're working with a small number of containers that are being installed/setup as a one-off then this is all fine, however, if you're launching containers for applications that need to be updated, changed/customised etc then you're probably best off taking a look at the [Docker Compose page.](https://bookstack.b4sed.xyz/books/linux/page/docker-compose)

====================================================================================

### Installation

Install Docker CE (Community Edition)

```
apt install docker.io
```

====================================================================================

### Commands &amp; Usage

<span class="EOP SCXO10967152 BCX0"><span class="TextRun SCXO10967152 BCX0" data-contrast="auto" lang="EN-GB" xml:lang="EN-GB"><span class="NormalTextRun SCXO10967152 BCX0">-------------------------------------------------------------------</span></span><span class="TextRun SCXO10967152 BCX0" data-contrast="auto" lang="EN-GB" xml:lang="EN-GB"><span class="NormalTextRun SCXO10967152 BCX0">-------------------------------------------------------------------</span></span><span class="TextRun SCXO10967152 BCX0" data-contrast="auto" lang="EN-GB" xml:lang="EN-GB"><span class="NormalTextRun SCXO10967152 BCX0">----------</span></span></span>

#### <span class="EOP SCXO10967152 BCX0"><span class="TextRun SCXO10967152 BCX0" data-contrast="auto" lang="EN-GB" xml:lang="EN-GB"><span class="NormalTextRun SCXO10967152 BCX0">Managing Containers</span></span></span>

##### List Docker processes/containers (running and stopped)

```
docker ps -a
```

##### Start a container

```
docker start containername
```

##### stop a container

```
docker stop containername
```

##### Delete a container

```
docker rm containername
```

##### Check container performance metrics

```
docker stats containername
```

<span class="EOP SCXO10967152 BCX0"><span class="TextRun SCXO10967152 BCX0" data-contrast="auto" lang="EN-GB" xml:lang="EN-GB"><span class="NormalTextRun SCXO10967152 BCX0">-------------------------------------------------------------------</span></span><span class="TextRun SCXO10967152 BCX0" data-contrast="auto" lang="EN-GB" xml:lang="EN-GB"><span class="NormalTextRun SCXO10967152 BCX0">-------------------------------------------------------------------</span></span><span class="TextRun SCXO10967152 BCX0" data-contrast="auto" lang="EN-GB" xml:lang="EN-GB"><span class="NormalTextRun SCXO10967152 BCX0">----------</span></span></span>

#### Adding new docker images

Docker has their own 'marketplace' of sorts for docker images:

[https://hub.docker.com/](https://hub.docker.com/)

##### To install a new docker image

```
docker pull container-name
```

##### List installed Docker images

```
docker images
```

##### Search locally installed images, and search Docker repository for available images

```
docker search name
```

<span class="EOP SCXO10967152 BCX0"><span class="TextRun SCXO10967152 BCX0" data-contrast="auto" lang="EN-GB" xml:lang="EN-GB"><span class="NormalTextRun SCXO10967152 BCX0">-------------------------------------------------------------------</span></span><span class="TextRun SCXO10967152 BCX0" data-contrast="auto" lang="EN-GB" xml:lang="EN-GB"><span class="NormalTextRun SCXO10967152 BCX0">-------------------------------------------------------------------</span></span><span class="TextRun SCXO10967152 BCX0" data-contrast="auto" lang="EN-GB" xml:lang="EN-GB"><span class="NormalTextRun SCXO10967152 BCX0">----------</span></span></span>

#### Launching Containers

====================================================================================

Basic launch for a container based on an image

```
docker run --name containername -it imagename
```

There are lots and lots of options available for the [docker run command](https://docs.docker.com/reference/cli/docker/container/run/):

Starting an instance with this method will push your shell into the container itself. To exit the container (continues running):

```
ctrl+p ctrl+x
```

To connect to a docker image:

```
docker attach containername
```

To connect to a docker image CLI:

```
docker exec -it containername bash
```

====================================================================================

====================================================================================