Skip to content

fahidnasir/docker-helper-scripts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

1. Docker Helper Scripts

This repository contains shell scripts for docker to automate/help routine operations.

1.1. Pre-Requisites

  1. Make the shell files executable
    • Navigate to the folder
    • Run the command: chmod +x *.sh

1.2. List of Scripts

1.2.1. docker_volume_clone.sh

This will create a new destination volume and copy all the files from source to this new destination volume.

./docker_volume_clone.sh name_or_id_of_source_volume destination_volume_name

1.2.1.1. Parameters

You can provide the following parameters as command line params or script will ask you to provide the value.

  1. SOURCE VOLUME
  2. DESTINATION VOLUME

1.2.1.2. Use Case

Before releasing a new version, copy all the files from the older volume to a new volume to attach it with the latest version.

1.2.1.3. How it works

  1. Check if parameters are provided
  2. Prompt for the missing parameter value(s)
  3. Check availability of Source volume (fails if doesn't exist)
  4. Check availability of Destination volume (fails if already exist)
  5. Create a data container from an official busybox image
    1. Mount both Source and Destination volumes into the container
    2. Run the copy command inside the data container to copy everything from source container to destination container.

1.2.2. docker_volume_get_info.sh

This script will list all the volumes with the attached stopped or running container IDs and disk space size.

./docker_volume_get_info.sh

1.2.2.1. Use Case

Docker doesn't provide an API to get size of docker volume. So instead of running multiple commands, Conveniently get all available volume(s) information by running this single script.

1.2.2.2. How it works

This script use busybox to mount volume and calculate the size of folder inside the volume using du library.

About

Shell scripts to automate docker related tasks

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages