DEV Community

Wycliffe A. Onyango
Wycliffe A. Onyango

Posted on

100 Days of DevOps: Day 37

Secure File Transfer to Docker Container

Objective

To securely transfer a confidential, encrypted file nautilus.txt.gpg from the Docker host system to a running container named ubuntu_latest, ensuring that the file is not altered during the process.

File Details

  • Source: /tmp/nautilus.txt.gpg (on Docker host)
  • Destination: /tmp/nautilus.txt.gpg (inside ubuntu_latest container)
  • Size: 2.05 KB
  • Type: GPG-encrypted confidential data

Steps Performed

  1. Verified Container Status

Confirmed that the ubuntu_latest container was running on App Server 1:

   docker ps
Enter fullscreen mode Exit fullscreen mode
  1. Executed File Transfer

Used the docker cp command to copy the encrypted file into the container:

   docker cp /tmp/nautilus.txt.gpg ubuntu_latest:/tmp/
Enter fullscreen mode Exit fullscreen mode

Output: Successfully copied 2.05kB to ubuntu_latest:/tmp/

  1. Verified File Presence Inside the Container

Ensured the file exists in the container’s /tmp directory with correct permissions:

   docker exec -it ubuntu_latest ls -l /tmp/nautilus.txt.gpg
Enter fullscreen mode Exit fullscreen mode

Output:

   -rw-r--r-- 1 root root 105 Sep  9 09:13 /tmp/nautilus.txt.gpg
Enter fullscreen mode Exit fullscreen mode

Outcome

The file was successfully copied without modification, maintaining its original size and integrity. This secure transfer ensures the encrypted data is now available within the containerized environment for further controlled processing or decryption.

Conclusion

This task demonstrates the secure and efficient movement of sensitive files into containerized environments using standard Docker utilities. Proper file handling practices were followed, aligning with the organization’s DevOps and security policies.

Top comments (0)