---
title: "进入docker容器的方法"
author: "daizj"
date: "2019-06-25T09:03:37Z"
tags: ["exec"]
categories: ["开源软件"]
slug: "docker"
draft: false
lastmod: "2019-06-25T09:03:37Z"
id: 2442121
url: "https://daizj.iteye.com/blog/2442121"
---

网上各种资料，进入容器有四种方法：
进入Docker容器比较常见的几种做法如下：

使用docker attach
使用SSH
使用nsenter
使用exec

其实最好用的是第四种： docker exec -it your-docker-container bash

第一种attach方法：  docker attach 容器ID  
会引起堵塞，中途中断命令，还会把容器给停止运行


