Create, tag, and optionally publish a container for a GIT repository.
The container tag has the format:
<name>:<version>- image created from Dockerfile without extension has also tag "latest"
The container name is generated based on the following precedence:
- The GIT
<organization>/<repository>of the 'origin' remote. - The top level GIT directory
- The current directory
The container version is generated based on the following precedence:
- Drone tag
- Drone branch
- GIT branch
- The string
unknown
- A .git directory in CWD or parent path
- One or more Dockerfiles in the project at the current working directory.
- File names match:
DockerfileandDockerfile.* - Dockerfiles SHOULD contain:
ARG TAG ARG GIT_DESCRIBE ARG GIT_SHA ARG BUILD_DATE ARG SRC_REPO LABEL TAG=$TAG \ GIT_DESCRIBE=$GIT_DESCRIBE \ GIT_SHA=$GIT_SHA \ BUILD_DATE=$BUILD_DATE \ SRC_REPO=$SRC_REPO - File names match:
- Docker installed on the localhost.
- [Optional] Tags will prefer a git repository but can work without it.
- Containerize will attempt to publish to the registries listed in a registry file, see Registry File Precedence
- Containerize will attempt to create repositories for some versions of Dockerhub (e.g. HPE's version), and AWS ECR
- The Namespace for HPE's Dockerhub is required to exist prior to running this utility
- The
-f <file>command line option - A user registry file:
<project_dir>/.dev/registry.json- Be sure to add
.dev/to the project.gitignorefile.
- Be sure to add
- A project registry file:
<project_dir>/registry.json - A program registry file in the docker image for containerize
Follow this example showing an unsecure private registry, a secure private registry, a secure aws ec2 registry: registry.json`
containerize.sh: Will build a container imagecontainerize.sh --publish: Will build and publish a container imagecontainerize.sh -q|--quiet: Will only print the tag<name>:<version>
- Get the containerize image:
- Build it from source:
./containerize.sh - Pull from registry:
docker pull containerize:latest
- Build it from source:
cd <project_dir>docker run --init --rm --workdir="$PWD" -v $HOME/.docker:/root/.docker -v /var/run/docker.sock:/var/run/docker.sock -v "$PWD":"$PWD" -e HTTP_PROXY -e HTTPS_PROXY -e NO_PROXY -e http_proxy -e https_proxy -e no_proxy containerize
clone:
tags: true
build:
create-container:
image: picasso/containerize:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- containerize.sh --publish
- Docker login not working:
- Identification:
WARNING: Error loading config file: .docker/config.json: open .docker/config.json: permission denied - Cause: If
docker loginhas not previously been run then the$HOME/.docker/config.jsonfile will not exist. Executing this tool will create it but may create it with root ownership. - Solution:
sudo rm -f $HOME/.docker/config.jsonand then run docker login again.
- Identification: