[[linux_wiki:docker_image_devel]]

Docker: Image Development

General Information

Developing docker images.

Checklist


Building/Testing Images


Build a docker image from a Dockerfile (mytag is usually a version number)

docker build -t myimagename:mytag --file=Dockerfile .


Run a container with an interactive terminal, remove it when stopped, attach a bash shell

docker run -it --rm --name mycontainername myimagename /bin/bash

Push Images To Docker Registry

Login to registry

  • Docker Hub
    docker login -u dockerhubuser
  • Private Registry
    docker login -u myuserhere https://registryhostname.my.domain.com


Tag a local image:tag with the destination image:tag (usually tag is a version number)

  • Docker Hub
    docker tag myimage:mytag dockerhubuser/myimage:mytag
  • Private Registry
    docker tag myimage:mytag registryhostname.my.domain.com/myimage:mytag


Push the image:tag to the remote registry

  • Docker Hub
    docker push dockerhubuser/myimage:mytag
  • Private Registry
    docker push registryhostname.my.domain.com/myimage:mytag


Additional tag with latest (so the most recent version number is also a latest tag)

  • Docker Hub
    docker tag myimage:mytag dockerhubuser/myimage:latest
  • Private Registry
    docker tag myimage:mytag registryhostname.my.domain.com/myimage:latest


Additional push for latest

  • Docker Hub
    docker push dockerhubuser/myimage:latest
  • Private Registry
    docker push registryhostname.my.domain.com/myimage:latest

Run Container From Registry

Login to registry

  • Docker Hub
    docker login -u dockerhubuser
    • Note: Login only required if docker hub registry is private (they are public by default).
  • Private Registry
    docker login -u myuserhere https://registryhostname.my.domain.com


Run container interactively with a bash shell (latest tag is default)

  • Docker Hub
    docker run -it --name mycontainername dockerhubuser/myimage /bin/bash
  • Private Registry
    docker run -it --name mycontainername registryhostname.my.domain.com/myimage /bin/bash

  • linux_wiki/docker_image_devel.txt
  • Last modified: 2019/07/21 20:10
  • by billdozor