Copy File to Docker Container

Опубликовано: 22 Апрель 2026
на канале: Otter Tech
6
0

In this practical Docker lab, we demonstrate how to transfer critical configuration files from a host server to a running container. This is a common DevOps task used for deploying certificates, GPG keys, or updated configuration files without needing to rebuild the entire image.

Lab Objectives

The goal of this session is to securely move a GPG key (nautilus.t.gpg) from App Server 2 into a specific directory within the ubuntu-latest container.

Key Procedural Steps:

Identify Target Environment:

Access App Server 2 (stapp02) using the credentials for user Steve.

Verify the target container is active by running docker ps.

The docker cp Command:

Utilize the docker cp (copy) utility, which allows for bidirectional file transfer between the host and container filesystems.

Execute the transfer from the source path on the host to the destination path inside the container: docker cp /tmp/nautilus.t.gpg ubuntu-latest:/home/.

Integrity Verification:

Log into the container's shell or use docker exec to list the files in the destination directory.

Confirm that nautilus.t.gpg is present in the /home/ directory and remains unmodified.

Mastering the docker cp command is essential for rapid troubleshooting and manual asset deployment in containerized environments.

#Docker #ContainerSecurity #GPG #DevOps #SysAdmin #Linux #Stapp02 #TechTutorial #OtterTech