Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue open-horizon#4225 - Bug: agent running inside container on MacO… #4226

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions anax-in-container/horizon-container
Original file line number Diff line number Diff line change
Expand Up @@ -253,12 +253,18 @@ start() {
fi
fi

dockerSocketPath="/var/run/docker.sock"
if [ ! -f dockerSocketPath ]; then
# Rancher desktop (with MobyD) uses $HOME/.rd/docker.sock instead of /var/run/docker.sock
dockerSocketPath="$HOME/.rd/docker.sock"
fi

# Start socat, if not already running
if isMacos; then
if ! isSocatRunning; then
# have docker api listen on a port, in addition to a unix socket
echo "Starting socat to listen on port $SOCAT_LISTEN_PORT and forward it to the docker API socket..."
socat TCP-LISTEN:$SOCAT_LISTEN_PORT,reuseaddr,fork UNIX-CONNECT:/var/run/docker.sock &
echo "Starting socat to listen on port $SOCAT_LISTEN_PORT and forward it to the docker API socket $dockerSocketPath..."
socat TCP-LISTEN:$SOCAT_LISTEN_PORT,reuseaddr,fork UNIX-CONNECT:$dockerSocketPath &
fi
fi

Expand Down Expand Up @@ -334,15 +340,16 @@ start() {
DOCKER_ADD_HOSTS="--add-host=$HZN_EXCHANGE_HOSTS"
fi

DOMAIN_SOCKET_MOUNT="/var/run/docker.sock:/var/run/docker.sock"
if [[ $DOCKER_ENGINE == "podman" ]]; then
# In the container, leave the mount as /var/run/docker.sock so the anax.service can stay the same
DOMAIN_SOCKET_MOUNT="/var/run/podman/podman.sock:/var/run/docker.sock"
dockerSocketPath="/var/run/podman/podman.sock"
fi

DOMAIN_SOCKET_MOUNT="$dockerSocketPath:/var/run/docker.sock"

if isMacos; then
DOCKER_HOST=tcp://host.docker.internal:$SOCAT_LISTEN_PORT
docker run $DOCKER_ADD_HOSTS -d -t --restart always --name $DOCKER_NAME --privileged -p 127.0.0.1:$HORIZON_AGENT_PORT:$anaxPort -e ANAX_DOCKER_ENDPOINT=${DOCKER_HOST} -e DOCKER_HOST=${DOCKER_HOST} -e HOST_OS=mac -e DOCKER_NAME=${DOCKER_NAME} -e HZN_VAR_RUN_BASE=/var/tmp/horizon/${DOCKER_NAME} $defaultFileMountArg $icpCertMount -v ${DOCKER_NAME}_var:/var/horizon/ -v ${DOCKER_NAME}_etc:/etc/horizon/ -v ${fssHostSharePath}:/var/tmp/horizon/${DOCKER_NAME} $dockerImage:$dockerTag
docker run $DOCKER_ADD_HOSTS -d -t --restart always --name $DOCKER_NAME --privileged -p 127.0.0.1:$HORIZON_AGENT_PORT:$anaxPort -e ANAX_DOCKER_ENDPOINT=${DOCKER_HOST} -e DOCKER_HOST=${DOCKER_HOST} -e HOST_OS=mac -e DOCKER_NAME=${DOCKER_NAME} -e HZN_VAR_RUN_BASE=/var/tmp/horizon/${DOCKER_NAME} -v ${DOMAIN_SOCKET_MOUNT} $defaultFileMountArg $icpCertMount -v ${DOCKER_NAME}_var:/var/horizon/ -v ${DOCKER_NAME}_etc:/etc/horizon/ -v ${fssHostSharePath}:/var/tmp/horizon/${DOCKER_NAME} $dockerImage:$dockerTag
checkrc $? "docker run"
else
${DOCKER_ENGINE} run $DOCKER_ADD_HOSTS -d -t --restart always --name $DOCKER_NAME --privileged -p 127.0.0.1:$HORIZON_AGENT_PORT:$anaxPort -e DOCKER_NAME=${DOCKER_NAME} -e HZN_VAR_RUN_BASE=${fssHostSharePath} -v ${DOMAIN_SOCKET_MOUNT} $defaultFileMountArg $icpCertMount -v ${DOCKER_NAME}_var:/var/horizon/ -v ${DOCKER_NAME}_etc:/etc/horizon/ -v ${fssHostSharePath}:${fssHostSharePath} $dockerImage:$dockerTag
Expand Down Expand Up @@ -560,3 +567,4 @@ case "$1" in
esac

exit