跳至页脚内容
使用 IRONSECUREDOC

Docker 容器列表(开发者工具如何工作)

In today’s fast-paced software development landscape, efficient deployment and management of applications are crucial. Docker has emerged as a leading solution for automating the deployment of applications within lightweight, portable containers. By encapsulating an application and its dependencies, Docker ensures consistent performance across different environments, from local development to production.

This containerization technology simplifies scalability and resource management, making it an essential tool in modern DevOps practices and continuous integration/continuous deployment (CI/CD) pipelines. In this article, we will explore the fundamentals of Docker, the concept of containers, and how it enhances the deployment process for applications, along with a closer look at IronSecureDoc, a document security tool that leverages Docker for scalable solutions.

What is Docker?

Docker is an open-source environment that automates the deployment of applications inside lightweight, portable containers. Containers package the application with all its dependent packages such that it will run exactly the same way irrespective of where the application executes; whether it is on a developer's laptop, a test server, or even in a production environment. Docker brings efficiency by keeping applications isolated from the underlying infrastructure, allowing multiple containers to run parallelly on the same host.

Docker Container List (How It Works For Developers): Figure 1 - Use-case for a Docker container

This simplifies scalability and resource management; with Docker, the development-to-production workflow is made easier and streamlined, hence a key player in modern DevOps and CI/CD pipelines.

What is a Container?

A container is a lightweight, self-contained, executable package containing everything needed to run software—from code and runtime to system tools, libraries, and settings in one bundle. This is an isolated environment from the host and other containers but shares the same operating system kernel, making it much more efficient and faster compared to traditional virtual machines.

Docker Container List (How It Works For Developers): Figure 2 - Visualization of a Docker Container

Docker containers are designed for portability. If a software developer can run it on their laptop for development and a tester can run it on a server for testing, then ideally a cloud environment or production environment can run that same stack of containers. The portability combined with the isolation and scalability of containers makes Docker an essential tool for modern software deployment and CI/CD pipelines.

Containers happen to be the core of Docker's functionality through which developers can assure that applications will work the same, regardless of where they will be deployed.

Listing Docker Containers

Among the operations you will carry out using Docker is listing containers, so you may be able to monitor their status or even manage them better. There are Docker commands for such an action, and this depends on whether you wish to print only running containers or all containers, including stopped ones.

Here is how you can list Docker containers:

1. Listing Running Containers

To list only the currently running containers, use the following docker ps command:

docker ps
docker ps
SHELL

This command will give the following columns:

  • Container ID: A unique identifier for a container.
  • Image: The Docker image based on which the container has been created.
  • Command: The command that the container is running.
  • Created: How long ago the container was created.
  • Status: Whether the container is running or exited.
  • Ports: A mapping of the port of the host with the container.
  • Names: The name assigned to the container, which may be generated automatically or set manually.

Docker Container List (How It Works For Developers): Figure 3 - Example of 'docker ps' command output

You can also use the newer command 'docker container ls', but we will be focusing on the 'docker ps' command syntax.

2. Listing All Containers (Running and Stopped)

To show all running and stopped containers, use the -a flag:

docker ps -a
docker ps -a
SHELL

This command returns the same columns as docker ps but includes stopped or exited containers, or all created containers. This command is handy for managing stopped containers or troubleshooting issues in containers that have crashed or exited.

Docker Container List (How It Works For Developers): Figure 4 - Output for the command 'docker ps -a'

3. Listing Container IDs Only

If you only need to display container IDs (which can be useful for scripting or automating actions), you can use the -q flag:

docker ps -q
docker ps -q
SHELL

The command docker ps -q will print only the running container IDs, allowing you to easily feed the IDs to other Docker commands for batch actions.

For example, one could stop every running container by combining this with docker stop:

docker stop $(docker ps -q)
docker stop $(docker ps -q)
SHELL

Docker Container List (How It Works For Developers): Figure 5 - Output of the command 'docker ps -q'

4. Filtering the List of Containers

You can also filter the output of the docker ps command based on specified criteria using the --filter option. Below is an example for only listing containers by status:

docker ps -f "status=exited"
docker ps -f "status=exited"
SHELL

This will only list containers that have exited. You can filter by the image name, labels, or any other custom criteria like ports or names.

Docker Container List (How It Works For Developers): Figure 6 - Output of the filtering command

5. Formatting the Output

For readability or custom output, Docker allows you to format the result using the --format option. For instance, to list only the container's ID and name, you can use:

docker ps --format "{{.ID}}: {{.Names}}"
docker ps --format "{{.ID}}: {{.Names}}"
SHELL

This is especially helpful when you are using Docker container management in scripts or tools where you may need certain pieces of information.

Docker Container List (How It Works For Developers): Figure 7 - Output of formatted docker ps command

What is IronSecureDoc?

IronSecureDoc is a document security tool designed to protect sensitive files by providing encryption, redaction, and digital signing features. It lets users secure PDF documents, controlling personal and confidential data in their possession. Some features include password protection, compliance with standards such as PDF/A, and digital certification, which is often used in legal, healthcare, or financial fields. The software is available as a REST API, making it highly integrative into different workflows, and it can be deployed on Docker for scalable, cloud-friendly security solutions.

Docker Container List (How It Works For Developers): Figure 8 - IronSecureDoc webpage

Features of IronSecureDoc

IronSecureDoc is quite impressive in terms of PDF security handling and document management. Its features include encryption, redaction, and digital signing:

  • Encryption: It offers PDF document encryption with 128 or 256-bit encryption with password-based security to maintain data confidentiality.
  • Redaction: This feature removes confidential data such as personal identifiers or other sensitive information, thus ensuring compliance with privacy standards and regulations.
  • Digital Signing: This has a digital signing feature with notarization of PDFs supporting .pfx or .p12, ensuring the document’s authenticity.
  • Compliance: It ensures compliance with PDF/A and PDF/UA standards, which is beneficial for archival and accessibility.
  • REST API: It has a flexible REST API that allows integration with other software and workflows.
  • Document Version Control: Provides version control to track all changes and version management for better document control.
  • Docker Integration: Native integration with Docker facilitates easier deployment in scalable cloud or on-premises environments.

These features make it a powerhouse tool for handling sensitive documents in law, health services, or financial sectors.

How to Pull IronSecureDoc into the Docker Container

Open a terminal window or Command Prompt and use this command to pull the IronSecureDoc Docker image from the repository:

docker pull ironsoftwareofficial/ironsecuredoc
docker pull ironsoftwareofficial/ironsecuredoc
SHELL

Docker Container List (How It Works For Developers): Figure 9 - Console output from pulling the IronSecureDoc Docker image

Running IronSecureDoc From a Container

Now that a container has pulled an image, we can run another command to initiate a running container called IronSecureDoc. We can use the -p flag for port mapping or the --rm flag to delete containers after stopping:

docker container run --rm -p 8080:8080 -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> -e ENVIRONMENT=Development -e HTTP_PORTS=8080 ironsoftwareofficial/ironsecuredoc:latest
docker container run --rm -p 8080:8080 -e IronSecureDoc_LicenseKey=<IRONSECUREDOC_LICENSE_KEY> -e ENVIRONMENT=Development -e HTTP_PORTS=8080 ironsoftwareofficial/ironsecuredoc:latest
SHELL

Docker Container List (How It Works For Developers): Figure 10 - Console output from running IronSecureDoc from a container

Using IronSecureDoc with Docker Container

IronSecureDoc can be used to redact, certify, and encrypt documents using its REST API after it has been installed and launched in Docker, as previously mentioned. Visit this link for API endpoints and documentation with Swagger UI once you have launched IronSecureDoc in a Docker container: http://localhost:8080/swagger/index.html.

Docker Container List (How It Works For Developers): Figure 11 - Swagger UI for API endpoints interaction

For example, you can send a POST request to the IronSecureDoc API to submit a document for encryption:

curl -X 'POST' \
  'http://localhost:8080/v1/document-services/pdfs/encrypt?user_password=demo' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@test.pdf;type=application/pdf'
curl -X 'POST' \
  'http://localhost:8080/v1/document-services/pdfs/encrypt?user_password=demo' \
  -H 'accept: */*' \
  -H 'Content-Type: multipart/form-data' \
  -F 'pdf_file=@test.pdf;type=application/pdf'
SHELL

This request sends the document to IronSecureDoc, applying the desired encryption.

Conclusion

Commands such as 'docker ps' and 'docker ps -a' make the management of Docker containers efficient by allowing easy monitoring, maintenance, and administration of running and stopped containers. Such commands help developers and system administrators filter, format, and manipulate containers in different environments, thereby enabling effective application management.

IronSecureDoc facilitates the deployment and scaling of document security features like encryption, redaction, and digital signing as a Docker container, ensuring maintained performance and security across different platforms. To know more about IronSecureDoc licensing, click here. Moreover, Iron Software offers various products to uplift your development project that you can further learn about here.

常见问题解答

Docker 如何自动化应用程序部署?

Docker 通过将应用程序及其所有依赖项打包到轻量级、可移植的容器中来自动化应用程序部署。这确保了应用程序在从开发到生产的不同环境中表现一致。

为什么容器对于现代软件开发很重要?

容器至关重要,因为它们提供了一个自包含的环境,其中包含应用程序所需的所有依赖项。这种隔离带来一致的性能,并简化了可扩展性和资源管理,这对于现代 DevOps 实践至关重要。

如何列出运行中的 Docker 容器?

您可以使用 docker ps 命令列出运行中的 Docker 容器。此命令提供诸如容器 ID、映像、状态等详细信息。

什么命令列出所有 Docker 容器,包括停止的?

要列出所有 Docker 容器,包括已停止的,使用 docker ps -a 命令。这对于 Docker 容器的管理和故障排除很有用。

如何根据特定标准过滤 Docker 容器?

您可以使用 --filter 选项过滤 Docker 容器列表。例如,docker ps -f "status=exited" 显示仅已退出的容器。

使用 Docker 的文档安全应用程序有哪些好处?

在文档安全应用程序中使用 Docker(如 IronSecureDoc)可以提供可扩展性和灵活性。它允许在安全、可扩展的环境中无缝集成和部署诸如加密、编辑和数字签名的功能。

如何拉取文档安全工具的 Docker 镜像?

您可以在终端中使用命令 docker pull ironsoftwareofficial/ironsecuredoc 拉取文档安全工具的 Docker 镜像。

哪些功能使文档安全工具适合 Docker 环境?

适合 Docker 环境的文档安全工具,如 IronSecureDoc,应包括 PDF 加密、编辑、数字签名功能及供集成的 REST API,这些功能都可以在容器内高效部署和管理。

如何自定义 Docker 命令输出以提高可读性?

您可以使用 Docker 命令中的 --format 选项自定义输出。例如,docker ps --format "{{.ID}}: {{.Names}}" 将仅显示容器的 ID 和名称。

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。