Skip to content

Instantly share code, notes, and snippets.

@kerasai
Last active September 3, 2019 18:37
Show Gist options
  • Save kerasai/b27969a6506bde8e5e0cd2ddd03576ca to your computer and use it in GitHub Desktop.
Save kerasai/b27969a6506bde8e5e0cd2ddd03576ca to your computer and use it in GitHub Desktop.
Create a docker image

The "magical" whale.

Creating Docker images for GitLab CI

  1. Remove existing image, if needed. See "Misc commands" for details.
  2. Build the new image docker build -t app .

To run a local image

  1. Find the image ID docker images
  2. docker run -t -d --name my_app <image ID>
  3. See below for information on how to test the image.

Tag the image

  1. docker tag app registry.gitlab.com/org/repo/php:latest
  2. Push the image to GitLab container repository docker push registry.gitlab.com/org/repo/php

Testing the image

  1. Start a container, named "my_app" docker run -t -d --name my_app app
  2. Open the command line within the container docker exec -it my_app bash
  3. Stop the container docker stop my_app app

Misc commands

  • View available images docker images
  • Remove an image docker rmi <IMAGE_ID>
  • Remove a container docker rm <CONTAINER_ID or CONTAINER_NAME>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment