跳過到頁腳內容
使用 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 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

除了開發之外,Curtis 對物聯網 (IoT) 有著濃厚的興趣,探索將硬體和軟體結合的創新方式。在閒暇時間,他喜愛遊戲並構建 Discord 機器人,結合科技與創意的樂趣。