5docker Notes
5docker Notes
(OR)
$docker run -d
-e SSO_HOST_URL
-e SSO_PASS
my-image
my_env.properties content
my_env_property=BLAH...
docker run
-p3000:3000
-v /containerDir/otherDir
-v hostDir:/containerDir
-d
imageId
Note
/containerDir/otherDir
will not be mapped to host
system because that
volume does not have
mapping for it. Which
means that dir will be
untouched and have same
content as when the image
got created.
OR
docker cp
<FILE_TO_COPY_FROM_HOST>
<CONTAINER_ID>:<PATH_INSID
E_CONTAINER_TO_PLACE_THE_F
ILE>
$ docker cp a.py
ubu_container:/home/dir1
Container to HOST
docker cp
<CONTAINER_ID>:<FILE_TO_CO
PY_INSIDE_CONTAINER>
<PATH__IN_HOST_TO_PLACE_FI
LE>
$ docker cp
ubu_container:/home/dir1/n
ew.txt /home/abhishek
Docker image commands
Save an image as tar docker save [OPTIONS] IMAGE [IMAGE…] docker save myrepository:1.0.1 -o
myrepository.tar
file
Save one or more
images to a tar
archive
$docker image ls
List changes to image $docker image history imageId
Delete images $docker rmi imageId
$docker rmi imageId imageId2
Once Dockerfile is defined, we can execute below command to create new image out of it.
$ docker build -t dockerUserId/myImageName:v1 .
COPY ./ ./
COPY ./package.json ./
ADD Similar to COPY If you want to add a xx.tar.gz to
a /usr/local in container, unzip it,
ADD provides additional features like remote and then remove the useless
URL and tar extraction support. compressed package.
For COPY:
COPY resources/jdk-7u79-linux-
x64.tar.gz /tmp/
RUN rm /tmp/jdk-7u79-linux-
x64.tar.gz
For ADD:
ADD resources/jdk-7u79-linux-
x64.tar.gz /usr/local/