Move version checking to Installation.

This commit is contained in:
wi1dcard 2019-01-27 09:32:51 +08:00
parent 509c3d6061
commit 7e21a61116

View file

@ -77,19 +77,20 @@ It is very important that you always know the current version of Docker you are
* [`docker version`](https://docs.docker.com/engine/reference/commandline/version/) shows which version of docker you have running.
Get the server version:
```
$ docker version --format '{{.Server.Version}}'
1.8.0
```bash
# Get the server version
docker version --format '{{.Server.Version}}'
```
You can also dump raw JSON data:
In Docker 1.8.0 and higher, you can also dump the raw JSON data:
```bash
docker version --format '{{json .}}'
```
$ docker version --format '{{json .}}'
will provide the output in JSON format:
```json
{"Client":{"Version":"1.8.0","ApiVersion":"1.20","GitCommit":"f5bae0a","GoVersion":"go1.4.2","Os":"linux","Arch":"am"}
```
@ -231,62 +232,6 @@ Images are just [templates for docker containers](https://docs.docker.com/engine
* [`docker history`](https://docs.docker.com/engine/reference/commandline/history) shows history of image.
* [`docker tag`](https://docs.docker.com/engine/reference/commandline/tag) tags an image to a name (local or registry).
## Checking Docker Version
It is very important that you always know the current version of Docker you are currently running on at any point in time.This is very helpful because you get to know what features are compatible with what you have running. This is also important because you know what containers to run from the docker store when you are trying to get template containers. That said let see how to know what version of docker we have running currently
* ['docker version'](https://docs.docker.com/engine/reference/commandline/version/) check what version of docker you have running
```bash
# Get the server version
docker version --format '{{.Server.Version}}'
```
In Docker 1.8.0 and higher, you can also dump the raw JSON data:
```bash
docker version --format '{{json .}}'
```
will provide the output in JSON format:
```json
{"Client":{"Version":"1.8.0","ApiVersion":"1.20","GitCommit":"f5bae0a","GoVersion":"go1.4.2","Os":"linux","Arch":"am"}
```
### Cleaning up
While you can use the `docker rmi` command to remove specific images, there's a tool called [docker-gc](https://github.com/spotify/docker-gc) that will safely clean up images that are no longer used by any containers. As of docker 1.13, `docker image prune` is also available for removing unused images. See [Prune](#prune).
### Load/Save image
Load an image from file:
```
docker load < my_image.tar.gz
```
Save an existing image:
```
docker save my_image:my_tag | gzip > my_image.tar.gz
```
### Import/Export container
Import a container as an image from file:
```
cat my_container.tar.gz | docker import - my_image:my_tag
```
Export an existing container:
```
docker export my_container | gzip > my_container.tar.gz
```
### Difference between loading a saved image and importing an exported container as an image
Loading an image using the `load` command creates a new image including its history.
Importing a container as an image using the `import` command creates a new image excluding the history which results in a smaller image size compared to loading an image.
## Networks
Docker has a [networks](https://docs.docker.com/engine/userguide/networking/) feature. Not much is known about it, so this is a good place to expand the cheat sheet. There is a note saying that it's a good way to configure docker containers to talk to each other without using ports. See [working with networks](https://docs.docker.com/engine/userguide/networking/work-with-networks/) for more details.