docker-documentation/general/updating-our-containers.md

73 wiersze
2.4 KiB
Markdown
Czysty Zwykły widok Historia

2019-01-24 20:51:38 +00:00
# Updating our containers
2019-02-06 19:03:28 +00:00
Our images are updated whenever the upstream application or dependencies get changed, so make sure you're always running the latest version, as they may contain important bug fixes and new features.
2019-01-24 20:51:38 +00:00
## Steps required to update
Docker containers are, for the most part, immutable. This means that important configuration such as volume and port mappings can't be easily changed once the container has been created. The containers created from our images run a very specific version of the application they wrap, so in order to update the application, you must recreate the container.
### Stop the container
Firstly, stop the container.
```bash
docker stop <container_name>
```
### Remove the container
Once the container has been stopped, remove it.
2019-09-29 09:44:22 +00:00
> **Important**: Did you remember to persist the `/config` volume when you originally created the container? Bear in mind, you'll lose any configuration inside the container if this volume was not persisted. [Read up on why this is important](volumes.md).
2019-01-24 20:51:38 +00:00
```bash
docker rm <container_name>
```
### Pull the latest version
Now you can pull the latest version of the application image from Docker Hub.
```bash
docker pull linuxserver/<image_name>
```
### Recreate the container
2019-09-29 09:44:22 +00:00
Finally, you can recreate the container. This is often cited as the most arduous task as it requires you to remember all of the mappings you set beforehand. You can help mitigate this step by using Docker Compose instead - this topic has been [outlined in our documentation](docker-compose.md).
2019-01-24 20:51:38 +00:00
```bash
docker create \
--name=<container_name> \
-v <path_to_data>:/config \
-e PUID=<uid> \
-e PGID=<gid> \
-p <host_port>:<app_port> \
linuxserver/<image_name>
```
2019-01-27 11:24:19 +00:00
2019-02-06 19:08:34 +00:00
## Docker Compose
It is also possible to update a single container using Docker Compose:
```bash
docker-compose pull linuxserver/<image_name>
docker-compose up -d <container_name>
```
Or, to update all containers at once:
```bash
2019-02-06 19:10:50 +00:00
docker-compose pull
2019-02-06 19:08:34 +00:00
docker-compose up -d
```
## Removing old images
Whenever a Docker image is updated, a fresh version of that image gets downloaded and stored on your host machine. Doing this, however, does not remove the _old_ version of the image. Eventually you will end up with a lot of disk space used up by stale images. You can `prune` old images from your system, which will free up space:
```bash
docker image prune
```
2019-03-16 13:24:50 +00:00