Skip to content

Instantly share code, notes, and snippets.

@afzouni
Last active March 3, 2024 07:13
Show Gist options
  • Save afzouni/efe66c8447a4828db454a4ab717f88a7 to your computer and use it in GitHub Desktop.
Save afzouni/efe66c8447a4828db454a4ab717f88a7 to your computer and use it in GitHub Desktop.
Docker Image ByPasser Script for Bypassing Sanctions and Filternet restrictions

Docker Image ByPasser Script for Bypassing Sanctions and Filternet restrictions

Introduction

This Bash script is a versatile tool designed to simplify the management of Docker images. It allows users to pull, retag, and manage Docker images, and it is especially useful for users facing network restrictions, sanctions, or filternet issues. The script enables you to bypass such restrictions by specifying custom proxy servers or using a default proxy server.

Installation

To use this script, follow these steps for installation:

  1. Download the Script:

    • Download the Bash script named docker-pull from this repository.
  2. Copy to a Directory in PATH:

    • Copy the downloaded script to a directory that is in your system's PATH. Common choices include:
      • /usr/local/bin/ (system-wide)
      • ~/.local/bin/ (user-specific)

    Example (assuming you are in the directory containing the script):

    sudo cp docker-pull /usr/local/bin/

Note: Use sudo if you're copying to a system-wide directory.

  1. Provide Execute Permission:
  • Ensure that the script has execute permissions. You can do this by running:

    chmod u+x /usr/local/bin/docker-pull

Usage

Once you've installed the script, you can use it to manage Docker images with the following syntax:

docker-pull <image_name> [proxy_server]

Basic Usage:

  • <image_name>: The name of the Docker image you want to retrieve and manage.

Example:

docker-pull nginx:latest

This command pulls the Docker image my_image using the default proxy server "docker.iranrepo.ir," retags it as my_image, and removes the proxy image. It is suitable for standard usage without specifying a custom proxy server.

Custom Proxy Server Usage:

  • <image_name>: The name of the Docker image you want to retrieve and manage.
  • [proxy_server]: The custom Docker proxy server URL.

Example:

docker-pull nginx:latest mycustomproxy.example.com

License

This script is licensed under the MIT License. You are free to use, modify, and distribute it as per the terms of the license.

Happy Docker Image ByPasser!

#!/bin/bash
# Define variables
image_name="$1"
# Check if the second argument is provided, otherwise use the default value
if [ -z "$2" ]; then
proxy_server="docker.arvancloud.ir"
else
proxy_server="$2"
fi
proxy_image_name="$proxy_server/$image_name"
# Pull the proxy image and retag it
docker pull "$proxy_image_name" && docker tag "$proxy_image_name" "$image_name"
# Remove the proxy image
docker rmi "$proxy_image_name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment