Questions about jenkins/ssh-agent:alpine docker image

I’m using this docker compose file to run a Jenkins agent

version: '3.7'
services:
  jenkins:
    image: jenkins/ssh-agent:alpine
    restart: unless-stopped
    ports:
      - 23:22
    container_name: jenkins-agent2
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /usr/bin/docker:/usr/bin/docker
      - /var/lib/docker/volumes:/home/jenkins/docker-volumes
    environment:
      JENKINS_AGENT_SSH_PUBKEY: MY KEY
      TZ: "America/Chicago"
    deploy:
      resources:
          limits:
            memory: 2G
          reservations:
            memory: 256M

At the end of the day what I’m trying to do is have Jenkins copy config files from github to the correct container volume. My flow is Jenkins creates the volume → Jenkins add config files to new volume-> Jenkins builds the container. I mostly have this working but had a few questions.

  1. What’s the best way to get the jenkins user that’s in the container to be able to run docker commands? The only way I could get this to work was on the host to change the GID of my docker group to match the GID of the jenkins user. I tired to use group_add: and user: in the docker compose file but everything I tried would cause the container to not start.

  2. I have my public key on the host under home/user/.ssh/jenkins_agent_key.pub is there a way in the compose file to pass the key form the host? I wasn’t sure how to update the compose file to pull the key from the host so i didn’t have to paste full key into the compose file.

  3. Everytime the container is rebuilt you have to replace the SSH Host Key finger print. Is there anyway around this? I tried to mount /ect/ssh to the container but then the agent was failing to start. This is the message I see on the master jenkins ui when the the agent is rebuilt Do you want to replace the SSH Host Key with fingerprint KEY with the SSH Host Key with fingerprint NEWKEY for all future connections to this host?YesNo