Add A File From A URL To Images
Create Dockerfile
# Build from base image
FROM ubuntu:latest
# Add file from URL to tmp directory
ADD ["https://raw.githubusercontent.com/chrisalbon/notes/master/LICENSE.txt", "/tmp/"]
Build Image From Dockerfile
Build the Dockerfile (docker build
) in the current directory (.
) and call the image chrisalbon/ubuntu:file-from-url (--tag chrisalbon/ubuntu:file-from-url
).
docker build --tag chrisalbon/ubuntu:file-from-url .
Sending build context to Docker daemon 4.608kB
Step 1/2 : FROM ubuntu:latest
---> 1e4467b07108
Step 2/2 : ADD ["https://raw.githubusercontent.com/chrisalbon/notes/master/LICENSE.txt", "/tmp/"]
Downloading 223B
---> 9ef46cc7fd3a
Successfully built 9ef46cc7fd3a
Successfully tagged chrisalbon/ubuntu:file-from-url
Run Docker Container From Image
Start and create (docker run
) an interative (-it
) Docker container from the image called chrisalbon/ubuntu:file-from-url
. Remove the container after it stops (-rm
)
docker run --rm -it chrisalbon/ubuntu:file-from-url
[email protected]:/#
View Destination Directory
View all files and folders (ls
) that displays using long format and shows hidden files (-al
) in the directory tmp
.
ls -al tmp/
total 12
drwxrwxrwt 1 root root 4096 Aug 20 00:38 .
drwxr-xr-x 1 root root 4096 Aug 20 00:42 ..
-rw------- 1 root root 223 Jan 1 1970 LICENSE.txt