Docker¶
Last updated on: 6 June, 2020
Compiled by: Evan Tay
In this section you will find my notes on using Docker for the deployment of Git projects.
Useful Docker commands¶
Tip
You do not have to write out the CONTAINER_ID
in full. The partial CONTAINER_ID
specified need only uniquely identify the container. Given a container 'aa151b912448' and 'aa153cd14238', docker logs aa15
will not work, but docker logs aa151
will.
Starting an interactive shell¶
1 |
|
Stopping and removing containers¶
1 2 |
|
docker ps
options:
-q
: Only display numeric IDs-a
: Show all containers (default shows just running)
Inspecting container metadata¶
1 |
|
Viewing container logs¶
Typical command:
1 |
|
Follow log output for a specified duration:
1 |
|
TIME can be a TIMESTAMP or relative (e.g. '10m' or '5s')
Docker and Github¶
Deploy script¶
This script assumes that the working directory contains a .git
directory, Dockerfile
and package.json
. A .gitignore
and a .dockerignore
file may be useful too. It is also assumed that the project dependencies have been installed using npm install
.
deploy.sh
1 2 3 4 5 6 7 8 9 10 11 |
|
Before the script can be used, replace the following placeholders:
IMAGE_NAME
: The name of your image.VERSION
: The version of your image. Can be left blank.CONTAINER_NAME
: The desired name of your container.CONTAINER_PORT
: The port of your container which your application is running on.HOST_PORT
: The host port your container port will be mapped to. This is the port that is exposed on the host system.