Skip to content

Commit

Permalink
[Docker] Update README and use better image name
Browse files Browse the repository at this point in the history
  • Loading branch information
pickypg committed Sep 17, 2024
1 parent 5fdcb21 commit ca8afbe
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 4 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Build files
build
diagnostic-output
target

# Support files
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -483,10 +483,10 @@ When the diagnostic is deployed within a Docker container it will recognize the
There are a number of options for interacting with applications running within Docker containers. The easiest way to run the diagnostic is simply to perform a `docker run -it` which opens a pseudo TTY. At that point you can interface with the diagnostic in the same way as you would when it was directly installed on the host. If you look in the _/docker_ directory in the diagnostic distribution you will find a sample script named `diagnostic-container-exec.sh` that contains an example of how to do this.

```$xslt
docker run -it -v ~/docker-diagnostic-output:/diagnostic-output support-diagnostics-app bash
docker run -it -v ~/docker-diagnostic-output:/diagnostic-output docker.elastic.co/support/diagnostics:latest sh
```

For the diagnostic to work seamlessly from within a container, there must be a consistent location where files can be written. The default location when the diagnostic detects that it is deployed in Docker will be a volume named _diagnostic-output_. If you examine the above script you will notice that it mounts that volume to a local directory on the host where the diagnostic loaded Docker container resides. In this case it is a folder named _docker-diagnostic-output_ in the home directory of the user account running the script. Temp files and the eventual diagnostic archive will be written to this location. You may change the volume if you adjust the explicit output directory whenever you run the diagnostic, but given that you are mapping the volume to local storage that creates a possible failure point. Therefore it's recommended you leave the _diagnostic-output_ volume name _as is_ and simply adjust the local mapping.
For the diagnostic to work seamlessly from within a container, there must be a consistent location where files can be written. The default location when the diagnostic detects that it is deployed in Docker will be a volume named `diagnostic-output`. If you examine the above script you will notice that it mounts that volume to a local directory on the host where the diagnostic loaded Docker container resides. In this case it is a folder named _docker-diagnostic-output_ in the home directory of the user account running the script. Temp files and the eventual diagnostic archive will be written to this location. You may change the volume if you adjust the explicit output directory whenever you run the diagnostic, but given that you are mapping the volume to local storage that creates a possible failure point. Therefore it's recommended you leave the `diagnostic-output` volume name _as is_ and simply adjust the local mapping.

## File Sanitization Utility

Expand Down
2 changes: 1 addition & 1 deletion docker-build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

docker build -f Dockerfile -t support-diagnostics-app .
docker build -f Dockerfile -t docker.elastic.co/support/diagnostics:latest .
2 changes: 1 addition & 1 deletion docker-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
# to create the output files.
#

docker run --network host -it -v ${PWD}/diagnostic-output:/diagnostic-output support-diagnostics-app sh
docker run --network host -it -v ${PWD}/diagnostic-output:/diagnostic-output docker.elastic.co/support/diagnostics:latest sh
41 changes: 41 additions & 0 deletions push-docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash

#
# Pushes Support Diagnostic images to hosted Docker.
#
# 1) Pushes the image tagged `latest` (which should have been built via
# `$ docker compose build`).
# 2) If a version was passed in:
# 2a) Add that version as a tag to latest.
# 2b) Push that newly tagged version to hosted Docker.
#
# Example usages:
# 1) Push latest
# $ ./push-docker.sh
# 2) Push latest and also tag as 9.1.1
# $ ./push-docker.sh 9.1.1
#

IMAGE="docker.elastic.co/support/diagnostics"

echo "$IMAGE"

echo "Pushing latest"

# NOTE: The pattern with ( set -x ; command ) makes it so that the command runs
# in a sub-shell where the command is echo'd to the screen when run. We don't
# want that mode permanently because the echo lines will duplicate in the console.
( set -x ; docker push "$IMAGE:latest" )

# If there is a version parameter passed in
if [[ $# -eq 1 ]]; then
VERSION=${1}

echo "Tagging version $VERSION"
( set -x ; docker tag "$IMAGE:latest" "$IMAGE:$VERSION" )

echo "Pushing version $VERSION"
( set -x ; docker push "$IMAGE:$VERSION" )
fi

echo "All done!"

0 comments on commit ca8afbe

Please sign in to comment.