Running Docker Commands
This action aims to run Docker commands on a host to build, push, pull, and run images. The following describes how to configure each command.
login and logout
- Search for and add action Run Docker Command.
- Select login or logout for Command.
Only self-hosted and SWR repositories are supported. You are advised to use the action Run Shell Commands to log in to or log out of a public repository.
When running the login command, retain the default value No for Restart Docker.
When you log in to a private repository, Docker provides a valid credential of the private repository in the .docker/config.json file. By default, the credential is encoded using Base64. You are advised to use docker-credential-pass and gpg to enhance Docker security.
- Select the image repository to be logged in to or logged out of. If no image repository is available, click Create.
The Create Service Endpoint: Docker repository dialog box is displayed, as shown in the following figure.
Table 1 Parameters Parameter
Description
Service Endpoint Name
Name of the service endpoint to the image repository. The name facilitates service endpoint selection and management.
Repository Address
Address of the image repository. You can use a self-hosted or SWR repository.
NOTE:The image repository address cannot contain the organization name or image name.
The repository address is in the https://XXXX.com or http://XXXX.com format.
Username
Username for logging in to the image repository.
Password
Password for logging in to the image repository.
- Log in to SWR.
- Log in to the console. In the upper left corner of the page, choose Service List > Containers > SoftWare Repository for Container. On the SWR console, choose My Images > Upload Through Client.
- In the displayed dialog box, click Generate a temporary login command.
- This topic uses the temporary command as an example. After you click Generate a temporary login command, the following dialog box is displayed.
- -u is followed by the username.
- -p is followed by the password.
- swr.XXXXX.com is the repository address.
- On the deployment page, add the service endpoint.
The repository URL must be in the https://XXXX.com or http://XXXX.com format.
The image repository address obtained by running the temporary command must be prefixed with https:// or http:.
- Click OK.
Then you can run the login command to log in to the image repository on CodeArts Deploy.
- To modify the information about an image repository, click Manage next to Image Repository in the action Run Docker Commands. On the displayed page, edit or delete the repository.
build
Preparations
To create a Docker image, upload the created Dockerfile to the target host in action Select Deployment Source.
Configuration Method
- Search for and add action Run Docker Command.
- Select the build command, enter the path where the Dockerfile is stored on the target host, and enter the execution parameters of the build command.
tag
- Search for and add action Run Docker Command.
- Select the tag command, enter the image to be tagged, and set the execution parameters (optional) of the tag command.
To add tags to multiple groups of images, separate the tags using newline characters.
run
- Search for and add action Run Docker Command.
- Select the run command and enter the execution parameters of the docker run command.
When running the run command, you cannot create or start a container in interactive mode. Instead, you must add the -d execution parameter so that the command can run in the background.
Others
- Search for and add action Run Docker Command.
- Select a command (push, pull, start, stop, restart, rm, or rmi) and enter the execution parameters of the command.
The command output similar to the following is displayed:
push: docker.test-registry.com/branch/Ubuntu:v1 pull: docker.test-registry.com/branch/Ubuntu:v1 rm: -f db01 db02 rmi: -f docker.test-registry.com/branch/Ubuntu:v1 start/stop/restart: container ID or name
If you encounter any problem during deployment, see Solutions to Common Problems.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot