Docker
Links
Quick notes
Commands
docker imagesdocker run -it ubuntu <shell>-v <host_dir>/<container_dir>-p--rm, automatically aremove the container when it exists
docker exec -it <container_name> bashdocker history <image>- 自下而上构建镜像层的缓存,
<...>: Already existes docker ps-afor all
UID
id, return user identity
- When we use file in host machine as volumem it’s important to set the SAME UID.
- Another way is mount your
/etc/groupand/etc/passwdto your container.- This method is post in the cooments under the post referenced above.
Alpine commands
Install packages only for building
apk add --no-cache --virtual .build-dependencies <packages>
apk del .build-dependencies
Add new user
RUN addgroup -S app && adduser -S -g app app
or
adduser -D -u 1000 [username]
Clear dangling data
Dangling data includes:
- containers stopped
- volumes without containers
- images with no containers
-afor unused data
# Command to run all prunes:
docker system prune
# Remove unused images
docker image prune
# Remove stopped containers.
docker container prune
# Remove unused volumes
docker volume prune
# Remove unused networks
docker network prune
docker rmi <image_name>, remove image