在 Docker 容器中运行
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
您还可以使用提供的 Dockerfile 和 docker-compose.yml 构建 Docker 容器,并在其中执行示例和开发 Google Ads API 应用。
为此,请在克隆此代码库的目录中运行以下命令(前提是您已安装 Docker 环境):
docker-compose up --build -d
这将提供一个已安装所有必需依赖项的 Docker 容器实例。
如需在 Docker 容器内打开 BASH shell,您可以运行 docker ps
获取容器 ID,然后运行:
docker exec -it <YOUR_CONTAINER_ID> bash
这样一来,您就可以在容器内运行代码示例和其他应用。
作为一种简写形式,如果您只在机器上运行一个 Docker 容器,也可以运行以下命令:
docker exec -it $(docker ps -a -q) bash
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-27。
[null,null,["最后更新时间 (UTC):2025-08-27。"],[[["\u003cp\u003eUtilize Docker for seamless execution of Google Ads API examples and application development within a pre-built environment.\u003c/p\u003e\n"],["\u003cp\u003eInitiate the Docker environment using \u003ccode\u003edocker-compose up --build -d\u003c/code\u003e after cloning the repository.\u003c/p\u003e\n"],["\u003cp\u003eAccess a BASH shell within the Docker container via \u003ccode\u003edocker exec -it <YOUR_CONTAINER_ID> bash\u003c/code\u003e to interact with code samples and applications.\u003c/p\u003e\n"],["\u003cp\u003eLeverage \u003ccode\u003edocker exec -it $(docker ps -a -q) bash\u003c/code\u003e as a shortcut for accessing the container when only one is running.\u003c/p\u003e\n"]]],[],null,["# Running in a Docker Container\n\nYou can also execute the examples and develop your Google Ads API application\ninside a Docker container, built using the provided\n[Dockerfile](https://github.com/googleads/google-ads-php/blob/HEAD/Dockerfile) and\n[docker-compose.yml](https://github.com/googleads/google-ads-php/blob/HEAD/docker-compose.yml).\n\nTo do so (provided that you have a Docker environment\n[installed](//docs.docker.com/install/)), run the following command in the\ndirectory where you cloned this repository: \n\n docker-compose up --build -d\n\nThis will provide a Docker container instance with all the required dependencies\nalready installed.\n\nTo open a BASH shell inside the Docker container, you can run `docker ps` to get\nthe container ID and then run: \n\n docker exec -it \u003cYOUR_CONTAINER_ID\u003e bash\n\nThis will allow you to run code examples and other applications inside the\ncontainer.\n\nAs a shorthand, in case you only have a single Docker container running on your\nmachine, you can also run: \n\n docker exec -it $(docker ps -a -q) bash"]]