This repository contains a Docker image for running CocoaPods commands without installing CocoaPods locally on your machine.
- Docker installed on your system
- Git (for repository clone)
- Build the Docker image:
docker build -t cocoapods-image .
- Add the environment variable to your shell configuration (e.g.,
~/.zshrc
):
export POD_CACHE_DIR=/path-to-this-folder/cocoapods-cache
- Reload your shell configuration:
source ~/.zshrc
Run CocoaPods commands from your iOS project directory:
docker run --rm -v $(pwd):/app -v $POD_CACHE_DIR:/home/poduser/.cocoapods cocoapods-image install
This command:
- Mounts your current directory to
/app
inside the container - Mounts the cache directory to preserve CocoaPods cache between runs
- Runs
pod install
in your project directory - Removes the container after execution (
--rm
flag)
You can replace install
with any other CocoaPods command:
# Update CocoaPods repositories
docker run --rm -v $(pwd):/app -v $POD_CACHE_DIR:/home/poduser/.cocoapods cocoapods-image repo update
# Run pod update
docker run --rm -v $(pwd):/app -v $POD_CACHE_DIR:/home/poduser/.cocoapods cocoapods-image update
This Docker image:
- Uses Ruby Alpine as the base image
- Installs necessary dependencies (build-base, git, rsync, bash, tcl, curl)
- Installs CocoaPods
- Creates a non-root user for better security
- Uses the CocoaPods command as the entrypoint
If you need additional packages for certain dependencies, you can uncomment and modify the following line in the Dockerfile:
# RUN apk add --no-cache ...
After making changes to the Dockerfile, rebuild the image:
docker build -t cocoapods-image .