📅  最后修改于: 2023-12-03 15:00:28.622000             🧑  作者: Mango
Docker is a platform designed to simplify the creation, deployment, and running of applications by using containers. A container is a standalone executable package that includes everything needed to run an application, including code, runtime, system tools, libraries, and settings.
One important aspect of using Docker is managing packages within containers. Docker dpkg is a command that allows developers to query, install, and remove packages within a container.
To list all packages installed in a container, use the dpkg -l
command. This will show all packages, their versions, and their descriptions.
docker exec <container_name> dpkg -l
To install a package within a container, use the dpkg -i
command. This will install the package and any dependencies it requires.
docker exec <container_name> dpkg -i <package_name>.deb
To remove a package within a container, use the dpkg -r
command. This will remove the package but will leave any dependencies that are shared by other packages.
docker exec <container_name> dpkg -r <package_name>
To remove a package and any dependencies that are no longer required, use the dpkg -P
command.
docker exec <container_name> dpkg -P <package_name>
Remember to use these commands with caution as they can affect the stability of your container. But with Docker dpkg, managing packages within your containers has never been easier!