You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用webdevops/*系列Docker容器?新手求使用指引

Using webdevops/* Docker Containers: A Practical Guide

Hey there! Glad you're diving into the webdevops/* Docker images—they’re a fantastic collection for streamlining web development, server management, and DevOps workflows. Since you already have a handle on docker run --rm, let’s build on that to put these images to work effectively.

Basic Usage (Leveraging docker run --rm)

The --rm flag is perfect for temporary test runs or one-off tasks because it automatically cleans up the container once it stops. Here’s a simple example to kick things off with an Apache web server:

docker run --rm -p 8080:80 webdevops/apache:latest
  • -p 8080:80 maps your host’s port 8080 to the container’s port 80, so you can access the server at http://localhost:8080.
  • The webdevops/apache:latest image pulls the most recent official Apache build from the repository.

Let’s walk through practical examples for some of the most useful images in the repo:

PHP + Apache Development Environment

If you’re working on a PHP project, this image lets you run your code instantly without setting up a local PHP stack:

docker run --rm -p 8080:80 -v $(pwd)/src:/app webdevops/php-apache:latest
  • -v $(pwd)/src:/app mounts your local src directory (where your PHP files live) into the container’s /app directory. Any changes you make locally will reflect immediately in the container.

Custom Nginx Reverse Proxy

Use this to spin up a configurable Nginx instance quickly:

docker run --rm -p 80:80 -v $(pwd)/nginx.conf:/opt/docker/etc/nginx/nginx.conf webdevops/nginx:latest
  • -v $(pwd)/nginx.conf:/opt/docker/etc/nginx/nginx.conf replaces the container’s default Nginx config with your custom file. This is great for setting up reverse proxy rules, SSL termination, or custom routing.

pgAdmin for PostgreSQL Management

Manage PostgreSQL databases via a web UI with minimal setup:

docker run --rm -p 5050:80 -e PGADMIN_DEFAULT_EMAIL=admin@example.com -e PGADMIN_DEFAULT_PASSWORD=secret webdevops/pgadmin:latest
  • -e sets environment variables to configure the initial admin account. Access pgAdmin at http://localhost:5050 using the credentials you provided.

Customizing Containers

Most webdevops images are highly configurable via environment variables and mounted files:

  • Environment Variables: Adjust service settings on the fly. For example, increase PHP’s memory limit:
    docker run --rm -p 8080:80 -e PHP_MEMORY_LIMIT=256M -v $(pwd)/src:/app webdevops/php-apache:latest
    
  • Mount Configuration Files: Most images store configs in /opt/docker/etc/. For Apache, you can override the default virtual host config by mounting your own file to /opt/docker/etc/apache2/vhost.conf.

Persisting Data (When --rm Isn’t Right)

While --rm is great for temporary tasks, you’ll want to persist data for services like databases. For example, with the webdevops/mysql image:

docker run -d -p 3306:3306 -v mysql-data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=mysecret webdevops/mysql:latest
  • -d runs the container in the background.
  • -v mysql-data:/var/lib/mysql uses a named Docker volume to persist MySQL data—even if you delete the container, your data stays intact.

To learn more about a specific webdevops image, run docker run --rm webdevops/<image-name>:latest help to view built-in documentation, or use docker inspect webdevops/<image-name>:latest to check exposed ports, default environment variables, and entrypoint details.

内容的提问来源于stack exchange,提问作者e-israel

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.08 15:57:57