Search code examples
dockerversion-control

Docker Container Version Control


Does anyone know of a good way to check the version of tools inside of Docker containers? Currently I am sshing into each container and checking the version. Ideally we would like to somehow expose the versions of our tools so we can just call the container with PHP – version and it tells us its version.

We are trying to make sure all of our different environments ( and local) have containers which share the same versions of our tools. In the past it has been an issue where locally we might be developing in PHP 5.5 but our production docker had PHP 5.4

Currently I am trying to set up a system that runs nightly and will slack our dev team if the versions of tools are different, but that requires sshing into each container.

Any better ideas to check versions of tools?


Solution

  • if you have the container id, you can run commands without entering the container in an interactive shell

    # docker exec  8b70c4db41e0 nginx -v
    nginx version: nginx/1.9.9
    

    To list all packages on Debian

    dpkg-query -l
    
        Desired=Unknown/Install/Remove/Purge/Hold
    | Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
    |/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
    ||/ Name                     Version                  Architecture Description
    +++-========================-========================-============-======================================================================
    ii  acl                      2.2.52-2                 amd64        Access control list utilities
    ii  adduser                  3.113+nmu3               all          add and remove users and groups
    ii  apt                      1.0.9.8.1                amd64        commandline package manager
    ii  base-files               8+deb8u2                 amd64        Debian base system miscellaneous files