Skip to content

Support podman in codebuild_build.sh #679

Open
@mbacchi

Description

@mbacchi

Describe the bug
Podman is an alternative to the Docker container engine, and fully compatible. On Linux it can typically replace docker by aliasing the command such as alias docker=podman. But when using podman, the codebuild_build.sh script does not work out of the box, and in fact I cannot get it to run at all without docker installed.

To Reproduce
Steps to reproduce the behavior:

  1. On Fedora Linux (37) Docker is not installed by default. Configure alias docker=podman in ~/.bashrc and spawn a new shell. Run codebuild_build.sh and you get many errors.
  2. Use this diff to try to make some minor changes to use podman:
diff -u codebuild_build.sh codebuild_build_new.sh 
--- codebuild_build.sh	2023-10-17 12:48:16.685661350 -0400
+++ codebuild_build_new.sh	2023-10-17 12:48:43.511815689 -0400
@@ -96,12 +96,12 @@
     exit 1
 fi
 
-docker_command="docker run -it "
+docker_command="podman run -it "
 if isOSWindows
 then
     docker_command+="-v //var/run/docker.sock:/var/run/docker.sock -e "
 else
-    docker_command+="-v /var/run/docker.sock:/var/run/docker.sock -e "
+    docker_command+="-v /run/user/1000/podman/podman.sock:/var/run/docker.sock -e "
 fi
 
 docker_command+="\"IMAGE_NAME=$image_name\" -e \
  1. When running the script now, I still get an error:
./codebuild_build.sh -i localhost/aws/codebuild/standard:6.0 -a /tmp/artifacts -s ./sourcedir/
Build Command:

podman run -it -v /run/user/1000/podman/podman.sock:/var/run/docker.sock -e "IMAGE_NAME=localhost/aws/codebuild/standard:6.0" -e "ARTIFACTS=/tmp/artifacts" -e "SOURCE=sourcedir" -e "INITIATOR=username" public.ecr.aws/codebuild/local-builds:latest

ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?

If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
  1. I've also tried setting DOCKER_HOST unsuccessfully.

Expected behavior
Should be able to run the images needed for the local codebuild build process.

Platform (please complete the following information):

  • OS: Fedora Linux 37 (x86)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions