Jul*_*oro 4 docker docker-compose docker-swarm
我想在我的Docker Swarm中运行它:
docker run --rm -it progrium/stress --cpu 2 --io 1 --vm 2 --vm-bytes 128M --timeout 10s
Run Code Online (Sandbox Code Playgroud)
所以我需要一个Docker-compose.yml
我应该如何在docker中使用此docker镜像来撰写并传递这些参数?
Jin*_*alu 27
Composerize will help you convert run command to a compose partially.
To understand it better I have described the components of the docker-compose.yml here.
image - image used to run the container
name - name of the service or container
command - command you want to run after the container is up
volumes - volume(s) you want to mount
Converting the run command from above to docker-compose:
version: "2/3/3.3/3.6" # based on the docker-compose version you use
services:
stress: # Service name, user defined
image: progrium/stress
command: '--cpu 2 --io 1 --vm 2 --vm-bytes 128M --timeout 10s'
Run Code Online (Sandbox Code Playgroud)
First two lines are common for any docker-compose file.
In docker-compose, the command allows the image to accept additional commands or options.
docker-compose.yml
version: "2"
services:
stress:
image: progrium/stress
command: '--cpu 2 --io 1 --vm 2 --vm-bytes 128M --timeout 10s'
Run Code Online (Sandbox Code Playgroud)
Compose the file with docker-compose as:
docker-compose up -d
Run Code Online (Sandbox Code Playgroud)
Multiple commands to the compose file:
command: bash -c "cd app/ && npm start"
Multi-line command to compose file:
command: >
bash -c "cd app/
&& npm start"
Run Code Online (Sandbox Code Playgroud)
version: "2/3/3.3/3.6" # based on the docker-compose version you use
services:
stress: # Service name, user defined
image: progrium/stress
command: '--cpu 2 --io 1 --vm 2 --vm-bytes 128M --timeout 10s'
Run Code Online (Sandbox Code Playgroud)
只需使用这个漂亮的小工具作为助手:https : //composerize.com/
或按照先前答案中突出显示的手动步骤操作...
| 归档时间: |
|
| 查看次数: |
8326 次 |
| 最近记录: |