docker build -t {tagname} . docker build -t $(basename "$PWD") .
docker run -d -P --name {tagname} {container_name} docker run -d -P --name $(basename "$PWD") $(basename "$PWD")
-d : detach mode -P : auto publish all ports -e : set env key=value pairs
docker port containername XPortNum
docker build -t $(basename "$PWD") . && docker run -d -P --name $(basename "$PWD") $(basename "$PWD");
docker rm
docker stop
docker stop $(docker ps -a | grep $(basename "$PWD") | awk '{print $1}');
docker rm $(docker ps -a | grep $(basename "$PWD") | awk '{print $1}');
docker build -t $(basename "$PWD") . &&
docker run -d -P --name $(basename "$PWD") $(basename "$PWD");
Or as a single line
docker stop $(docker ps -a | grep $(basename "$PWD") | awk '{print $1}'); docker rm $(docker ps -a | grep $(basename "$PWD") | awk '{print $1}'); docker build -t $(basename "$PWD") . && docker run -d -P --name $(basename "$PWD") $(basename "$PWD");
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
- ENTRYPOINT is runs WITH cmd,
- CMD is commonly overwritten by user
- Technically user can overwrite ENTRYPOINT with additional command "flags"
- Final executed command : ENTRYPOINT CMD