Skip to content

Commit

Permalink
build: improve Docker container IP extraction method
Browse files Browse the repository at this point in the history
- Replace Docker setup with extraction of container IP from /etc/hosts

Signed-off-by: appleboy <[email protected]>
  • Loading branch information
appleboy committed Jun 6, 2024
1 parent a369394 commit c3194c4
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/ipv6.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Docker
- name: Get Container IP from /etc/hosts
run: |
# Get the container ID of the current container
CONTAINER_ID=$(cat /proc/self/cgroup | grep 'docker' | sed 's/^.*\///' | tail -n 1)
echo "Container ID: $CONTAINER_ID"
# Get the container IP address using docker inspect
CONTAINER_IP=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $CONTAINER_ID)
# Extract the container IP from /etc/hosts
CONTAINER_IP=$(grep $(hostname) /etc/hosts | awk '{ print $1 }')
echo "Container IP: $CONTAINER_IP"
# Set the container IP as an environment variable
Expand Down

0 comments on commit c3194c4

Please sign in to comment.