无法连接到docker守护程序

时间:2016-04-04 21:59:33

标签: docker docker-compose

我在ec2实例上安装了docker和docker-compose。我也开始使用docker但是当我尝试使用docker-compose时出现错误:

docker-compose

我也尝试过使用sudo的命令,但它不会将DOCKER_HOST识别为命令

我没有设置任何using System; using System.Linq; using System.Collections.Generic; using Microsoft.VisualStudio.TestTools.UnitTesting; using Lucene.Net.Search; using Lucene.Net.Index; using Lucene.Net.Analysis.Standard; using Lucene.Net.QueryParsers; using Lucene.Net.Documents; using Lucene.Net.Store; namespace SO_answers { [TestClass] public class UnitTest1 { [TestMethod] public void TestShopping() { var item = new Dictionary<string, string> { {"field1", "value1" }, {"field2", "value2" }, {"field3", "value3" } }; var writer = CreateIndex(); Add(writer, item); writer.Flush(true, true, true); var searcher = new IndexSearcher(writer.GetReader()); var result = Search(searcher, item); Assert.AreEqual(1, result.Count); writer.Dispose(); } private List<string> Search(IndexSearcher searcher, Dictionary<string, string> values) { var query = new BooleanQuery(); foreach (var termQuery in values.Select(kvp => new TermQuery(new Term(kvp.Key, kvp.Value.ToLowerInvariant())))) query.Add(new BooleanClause(termQuery, Occur.MUST)); return Search(searcher, query); } private List<string> Search(IndexSearcher searcher, Query query) { var sortField = new SortField("creationDate", SortField.LONG, true); var inverseSort = new Sort(sortField); var results = searcher.Search(query, null, 100, inverseSort); // exception thrown here var result = new List<string>(); var matches = results.ScoreDocs; foreach (var item in matches) { var id = item.Doc; var doc = searcher.Doc(id); result.Add(doc.GetField("creationDate").StringValue); } return result; } IndexWriter CreateIndex() { var directory = new RAMDirectory(); var analyzer = new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_30); var writer = new IndexWriter(directory, analyzer, new IndexWriter.MaxFieldLength(1000)); return writer; } void Add(IndexWriter writer, IDictionary<string, string> values) { var document = new Document(); foreach (var kvp in values) document.Add(new Field(kvp.Key, kvp.Value.ToLowerInvariant(), Field.Store.YES, Field.Index.ANALYZED)); document.Add(new NumericField("creationDate", Field.Store.YES, true).SetLongValue(DateTime.UtcNow.Ticks)); writer.AddDocument(document); } } } 环境变量。我不确定我是否需要..

1 个答案:

答案 0 :(得分:1)

您需要使用sudo运行实际命令:

sudo docker-compose -p docker -f my-compose.yml up -d

Docker在Linux系统上以root身份运行,因此与运行守护程序的所有交互都需要以root身份运行。您可以以用户身份运行命令,但是您没有与正在运行的系统进行交互!

您可以使用以下命令在Amazon Linux上安装docker-compose:

curl -L https://github.com/docker/compose/releases/download/1.4.0/docker-compose-`uname -s`-`uname -m` | sudo tee /usr/local/bin/docker-compose > /dev/null
sudo chmod +x /usr/local/bin/docker-compose