Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

CommandDescription
docker-compose versionList information about the docker-compose version
docker-compose --versionList limited information

docker-compose up -d

Start all services defined in the docker-compose file - create and start the container(s)
docker-compose up -d servicenameStart a specific service defined in the docker-compose file
docker-compose psList all running containers in the current docker-compose project directory; including name, command, state, and ports
docker-compose eventsStreams events for containers in the compose project.  This is similar to docker events, but there are no filters allowed other than ---json.  Exit by using Control C
docker-compose imagesSimilar to docker-compose ps; lists the container name and information about the image(s)
docker-compose configValidate and view the compose file complete/combined with other configuration files such as the docker-compose.override.yml
docker-compose logsView the container logs - specific .  Specific containers can be listed.  Use the -t option to show timestamps, and --tail="xx" to  indicate the number of lines to show from the end of the logs for each container.  To follow the log, use the -f option (and control C to end).
docker-compose pause/unpausePauses the running containers.  Note that the unpause (not start) command has to be used in order to restore the containers to their normal state.
docker-compose start/restartStart or restart existing containers
docker-compose stopStop containers (note this does not remove the containers)

docker-compose rm

Remove a specific service/container
docker-compose rm -fvRemove a specific service/container and the volume (use with extreme caution)
docker-compose downStop AND remove containers,networks, volumes, and images created by docker-compose up.  See parameters - by default does not remove volumes

...

Code Block
languagebash
docker version
Client:
 Version:      17.06.1-ce
 API version:  1.30
 Go version:   go1.8.3
 Git commit:   874a737
 Built:        Thu Aug 17 22:51:12 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.06.1-ce
 API version:  1.30 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   874a737
 Built:        Thu Aug 17 22:50:04 2017
 OS/Arch:      linux/amd64
 Experimental: false

docker --version
Docker version 17.06.1-ce, build 874a737
==========================================================================================
docker ps
CONTAINER ID        IMAGE                                     COMMAND                  CREATED             STATUS              PORTS                 NAMES
7fe68d95c210        994bd903dd2b                              "catalina.sh run"        12 days ago         Up 8 days           8080/tcp, 44000/tcp   uat1_usasapp_1
8fbe19fb0883        jwilder/nginx-proxy:alpine                "/app/docker-entry..."   13 days ago         Up 8 days           0.0.0.0:80->80/tcp    proxy_proxy_1
0d35a2a79cb8        nginx                                     "nginx -g 'daemon ..."   13 days ago         Up 8 days           80/tcp                proxy_index_1
31670b7f3aa4        eb53a4148083                              "catalina.sh run"        13 days ago         Up 8 days           8080/tcp, 44001/tcp   uat1_uspsapp_1
cdf27f03f618        docker-dev.ssdt.io/usps-live-db:fayette   "/docker-entrypoin..."   13 days ago         Up 8 days           5432/tcp              uat1_uspsdb_1
7a2f60bf67f0        docker-dev.ssdt.io/usas-live-db:fayette   "/docker-entrypoin..."   13 days ago         Up 8 days           5432/tcp              uat1_usasdb_1

docker ps -a
CONTAINER ID        IMAGE                                     COMMAND                  CREATED             STATUS                     PORTS                 NAMES
7fe68d95c210        994bd903dd2b                              "catalina.sh run"        12 days ago         Up 8 days                  8080/tcp, 44000/tcp   uat1_usasapp_1
22c6ed44c4d0        994bd903dd2b                              "catalina.sh run"        12 days ago         Exited (143) 2 hours ago                         test_usasapp_1
226b79168740        docker.ssdt.io/ssdt-postgres:5            "ssdt-entrypoint.s..."   12 days ago         Exited (137) 2 hours ago                         test_usasdb_1
8fbe19fb0883        jwilder/nginx-proxy:alpine                "/app/docker-entry..."   13 days ago         Up 8 days                  0.0.0.0:80->80/tcp    proxy_proxy_1
e3c5a5243ba2        jwilder/docker-gen                        "/usr/local/bin/do..."   13 days ago         Exited (0) 8 days ago                            proxy_index-gen_1
0d35a2a79cb8        nginx                                     "nginx -g 'daemon ..."   13 days ago         Up 8 days                  80/tcp                proxy_index_1
31670b7f3aa4        eb53a4148083                              "catalina.sh run"        13 days ago         Up 8 days                  8080/tcp, 44001/tcp   uat1_uspsapp_1
cdf27f03f618        docker-dev.ssdt.io/usps-live-db:fayette   "/docker-entrypoin..."   13 days ago         Up 8 days                  5432/tcp              uat1_uspsdb_1
7a2f60bf67f0        docker-dev.ssdt.io/usas-live-db:fayette   "/docker-entrypoin..."   13 days ago         Up 8 days                  5432/tcp              uat1_usasdb_1

docker ps | grep usps
31670b7f3aa4        eb53a4148083                              "catalina.sh run"        13 days ago         Up 8 days           8080/tcp, 44001/tcp   uat1_uspsapp_1
cdf27f03f618        docker-dev.ssdt.io/usps-live-db:fayette   "/docker-entrypoin..."   13 days ago         Up 8 days           5432/tcp              uat1_uspsdb_1

==========================================================================================
docker-compose version
docker-compose version 1.15.0, build e12f3b9
docker-py version: 2.4.2
CPython version: 2.7.13
OpenSSL version: OpenSSL 1.0.1t  3 May 2016

docker-compose --version
docker-compose version 1.15.0, build e12f3b9
==========================================================================================
docker images
REPOSITORY                        TAG                 IMAGE ID            CREATED             SIZE
docker.ssdt.io/usas-app           pilot               0ec6435ca1d2        5 days ago          588MB
docker.ssdt.io/usas-app           uat                 0ec6435ca1d2        5 days ago          588MB
docker.ssdt.io/usps-app           pilot               bd151f3cf8ff        5 days ago          594MB
docker.ssdt.io/usps-app           uat                 bd151f3cf8ff        5 days ago          594MB
docker.ssdt.io/usps-app           <none>              be5ebd57ec36        6 days ago          594MB
docker.ssdt.io/usps-app           <none>              43fa507afec2        8 days ago          594MB
docker.ssdt.io/usps-app           <none>              c65b8f741bba        12 days ago         594MB
docker.ssdt.io/usas-app           <none>              994bd903dd2b        2 weeks ago         588MB
jwilder/nginx-proxy               alpine              10d86b332e6d        2 weeks ago         51.2MB
docker.ssdt.io/usps-app           <none>              eb53a4148083        2 weeks ago         594MB
docker-dev.ssdt.io/usas-live-db   fayette             cd379841bb57        4 weeks ago         813MB
nginx                             latest              b8efb18f159b        5 weeks ago         107MB
jwilder/docker-gen                latest              4f4702d334a3        5 weeks ago         19.6MB
docker.ssdt.io/ssdt-postgres      5                   a45f1611ebec        5 weeks ago         272MB
docker-dev.ssdt.io/usps-live-db   fayette             a98717c515f0        4 months ago        590MB
docker.ssdt.io/ssdt-utils         latest              6d6bffa72cb1        11 months ago       284MB

docker images | grep usps-app
docker.ssdt.io/usps-app           pilot               bd151f3cf8ff        5 days ago          594MB
docker.ssdt.io/usps-app           uat                 bd151f3cf8ff        5 days ago          594MB
docker.ssdt.io/usps-app           <none>              be5ebd57ec36        6 days ago          594MB

==========================================================================================
 docker inspect docker.ssdt.io/usas-app:pilot
[
    {
        "Id": "sha256:0ec6435ca1d240e969dbdc91592ba808d440b01bbf8304030a028b9ba4c40624",
        "RepoTags": [
            "docker.ssdt.io/usas-app:pilot",
            "docker.ssdt.io/usas-app:uat"
        ],
        "RepoDigests": [
            "docker.ssdt.io/usas-app@sha256:d8c0505d7947e6dcf852c27365f12ffe274d2ee45460265bf4a1f0dce3607610"
        ],
<--and a lot more information-->

docker inspect docker.ssdt.io/usas-app:pilot | grep Author
        "Author": "Dave Smith <smith@nwoca.org>",

==========================================================================================
docker exec -it uat1_uspsdb_1 /bin/bash
root@cdf27f03f618:/#

<--Example to be able to look at the database in a container-->
docker exec -it uat1_uspsdb_1 /bin/bash
root@cdf27f03f618:/# su - postgres
No directory, logging in with HOME=/
$ psql
psql (9.4.5)
Type "help" for help.

postgres=#
==========================================================================================
 docker stats --format "table {{.Name}}\t{{.MemUsage}}\t{{.MemPerc}}"
NAME                           MEM USAGE / LIMIT     MEM %
matt_usasapp_1                 1.524GiB / 127.9GiB   1.19%
matt_usasdb_1                  6.223MiB / 127.9GiB   0.00%
andreadev_uspsdb_1             3.277MiB / 127.9GiB   0.00%
loridev_uspsdb_1               3.094MiB / 127.9GiB   0.00%

==========================================================================================
docker system prune
WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all dangling images
        - all build cache 

docker system prune --all --force --volumes

WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all volumes not used by at least one container
        - all images without at least one container associated to them
        - all build cache

####USE THE FOLLOWING WITH EXTREME CAUTION - IT IS USED IF YOU NEED TO COMPLETELY CLEAN A DOCKER SYSTEM#####
docker container stop $(docker container ls -a -q) && docker system prune -a -f --volumes

======================================================================================================
 docker events --since '2018-09-08' --filter 'event=start'
2018-09-08T01:00:02.781591655-04:00 container start 5fa3c484b220d181289c104de58e93fa0396444847ab19b8ea01623fb19dcc88 (image=docker.ssdt.io/ssdt-utils, name=keen_fermat)
2018-09-09T01:00:02.308893519-04:00 container start 3f9679fa25aad836f380a42dc788f387fe7effc3567266a88b298e25738b5d8f (image=docker.ssdt.io/ssdt-utils, name=determined_jang)
2018-09-10T01:00:02.423988779-04:00 container start 12439e76463b53eff767127a7dfc3a47caa17b9d31e0dfa0b115a77a6058be26 (image=docker.ssdt.io/ssdt-utils, name=goofy_yonath)
2018-09-11T01:00:02.575341961-04:00 container start dafa834df165512b0e5db80943e69a3733ddad38bed3b00543a4303ad04cd6ff (image=docker.ssdt.io/ssdt-utils, name=goofy_wing)

###Common docker-compose logs syntax
##Last 50 lines of the uspsapp log
docker-compose logs --tail=50 uspsapp
##Follow the usasapp log
docker-compose logs -f usasapp
Ctrl C to end
##Show certain keywords in a log - in this case it is looking for the word loading in the log
docker-compoes logs usasapp | grep 'loading'