Docker使用

2024-07-20-docker使用

How to keep Docker container running after starting services? https://stackoverflow.com/questions/25775266/how-to-keep-docker-container-running-after-starting-services

ENTRYPOINT [“tail”, “-f”, “/dev/null”] CMD[“sleep”, “1d”] CMD[“sleep”, “infinity”]

you can run plain cat without any arguments as mentioned by bro @Sa’ad to simply keep the container working [actually doing nothing but waiting for user input] (Jenkins’ Docker plugin does the same thing)

This is not really how you should design your Docker containers.

When designing a Docker container, you’re supposed to build it such that there is only one process running (i.e. you should have one container for Nginx, and one for supervisord or the app it’s running); additionally, that process should run in the foreground.

The container will “exit” when the process itself exits (in your case, that process is your bash script).

However, if you really need (or want) to run multiple service in your Docker container, consider starting from “Docker Base Image”, which uses runit as a pseudo-init process (runit will stay online while Nginx and Supervisor run), which will stay in the foreground while your other processes do their thing.

They have substantial docs, so you should be able to achieve what you’re trying to do reasonably easily.

win10 WSL 安装 ubuntu

win10 端口转发

netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=2222 connectaddress=172.19.74.239 connectport=2222

Dockerfile例子

FROM ubuntu:latest
RUN apt-get update && apt-get install -y \
unzip \
cmake \
make \
build-essential \
zlib1g-dev \
openssl \
libssl-dev \

docker build .

给image id 修改名字 docker tag xxx ubuntu_env