Strony

2016-04-27

Docker: podstawowe polecenia

Lista lokalnych obrazów

Warto czasem zobaczyć jakie mamy obrazy na dysku:

$ docker images

REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
dpz/wildfly-blueocr   latest              22af6d6fe20c        41 hours ago        4.791 GB
dpz/opencv            latest              7124e8b011a8        41 hours ago        4.765 GB
dpz/wildfly           latest              00f0de2d3fdc        41 hours ago        1.397 GB
dpz/system            latest              f1ef0b164424        41 hours ago        1.098 GB
centos                7                   778a53015523        4 weeks ago         196.7 MB
trigsoft/wildfly      latest              a251fdfa8320        10 weeks ago        635.4 MB

Usunięcie obrazów i kontenerów

Pracując z Dockerem możesz natknąć się na problem z dużą liczbą obrazów i kontenerów. Aby je wszystkie usunąć jedną komendą wystarczy:

# Delete all containers
docker rm $(docker ps -a -q)
# Delete all images
docker rmi $(docker images -q)

Jeśli chcesz usunąć nieoznaczone obrazy wystarczy:

#!/bin/bash
# Delete untagged images (dangling)
docker rmi -f $(docker images -q --filter "dangling=true")

Wyszukiwanie obrazów

Wyszukiwanie obrazów z repo Dockera

$ docker search wildfly

NAME                         DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
jboss/wildfly                WildFly application server image                185                  [OK]
openshift/wildfly-8-centos   DEPRECATED - see openshift/wildfly-81-centos7   6                    [OK]
piegsaj/wildfly              WildFly 10.0.0.Final on Java 8                  4                    [OK]
centos/wildfly                                                               3                    [OK]
andreptb/wildfly             Debian Jessie based image with JBoss Wildf...   2                    [OK]
emedeiros/wildfly            WildFly 9.0.2.Final with OpenJDK 8              1                    [OK]
sewatech/wildfly             Debian + WildFly, in HA mode                    1                    [OK]
trigsoft/wildfly             WildFly 10.0.0 + Java 8 + PostgreSQL 9.4        1                    [OK]
ceagan/wildfly               JBoss Wildfly with XMLStarlet                   1                    [OK]
hpehl/wildfly-domain         WildFly domain with one domain controller ...   1                    [OK]
projectomakase/wildfly       Docker image for WildFly                        0                    [OK]
huggosantos/wildfly-mysql    wildfly-mysql                                   0                    [OK]
dthuilot/wildfly-admin       wildfly with admin console enabled.             0                    [OK]
huggosantos/wildfly           Wildfly version 9.0.2.Final                    0                    [OK]
khipu/wildfly                Wildfly 10 / openjdk 8 / alpine 3 and cust...   0                    [OK]
vereshus/wildfly             Wildfly application server with Java 8.         0                    [OK]
caltha/wildfly               Self contained WildFly application server       0                    [OK]
ifbaeunapolis/wildfly        wildfly                                         0                    [OK]
cnry/wildfly                 WildFly Application Server                      0                    [OK]
sledsoft/wildfly                                                             0                    [OK]
bitnami/wildfly              Bitnami WildFly Docker Image                    0                    [OK]
jamesnetherton/wildfly       A minimalistic Docker image for WildFly ru...   0                    [OK]
dcm4che/wildfly              wildfly based on 8-jre for dcm4che/archive 5    0                    [OK]
mihahribar/wildfly           Dockerfile for Wildfly running on Ubuntu 1...   0                    [OK]
dolphindev/wildfly           OpenDolphin application server created on ...   0                    [OK]

Pobieranie obrazu z repo

Aby pobrać przykładowe repo trigsoft/wildfly, na którym jest WildFly 10.0.0 + Java 8 + PostgreSQL 9.4 wystarczy użyć prostej komendy:

$ docker pull trigsoft/wildfly

Using default tag: latest
latest: Pulling from trigsoft/wildfly
a3ed95caeb02: Pull complete
a07226856d92: Pull complete
17a00fa8d5c0: Pull complete
132e3c60d9a9: Pull complete
f60acd56d870: Pull complete
271ea3c24483: Pull complete
0ad07189dd16: Pull complete
a3d975cb837d: Pull complete
d7102d6afcc6: Pull complete
688ac970b5ea: Pull complete
c30a372a098b: Pull complete
07c3dd598370: Pull complete
cf3cecce1b1d: Pull complete
b29101bafc07: Pull complete
Digest: sha256:a2c25fdbc4a37afa9c2ee559a3eceacbfe7128eacf0a5dc7c846f54542043ff3
Status: Downloaded newer image for trigsoft/wildfly:latest

źródło: techoverflow.net