Unzip a File in the Temp Directory in Docker Container

Unzip a File in the /tmp/ Directory on a Docker Container

How to unzip a file located in the /tmp/ directory on a Docker container using PuTTY:

1. Open PuTTY

  • Start PuTTY and connect to the Docker host or container.

  • Use the appropriate credentials to log in.

2. Navigate to the /tmp Directory

  • Change to the /tmp directory where your file is located:

cd /tmp

3. Unzip the File

  • If the file is a .zip file, use the unzip command:

unzip <filename>.zip

  • If unzip is not installed, you can install it (assuming the container allows package installation):

Code
apt-get update && apt-get install -y unzip  # For Debian/Ubuntu-based containers
yum install -y unzip # For RHEL/CentOS-based containers

4. Verify the Contents

  • Check the extracted contents:

ls


5. Exit the Container

  • Once done, type:

exit

  • This exits the container's shell.


Notes:

  • For .tar.gz Files: Use tar -xzvf instead of unzip:

tar -xzvf <filename>.tar.gz

  • For Limited Containers: If the container doesn’t allow installing tools, consider copying the file to the host, extracting it there, and copying it back:

Code
docker cp <container_name_or_id>:/tmp/<filename>.zip /path/on/host
unzip /path/on/host/<filename>.zip -d /path/on/host/unzipped/
docker cp /path/on/host/unzipped/ <container_name_or_id>:/tmp/